jquery - change CSS then Load HTML file not Working -
this hard answer. use jquery manipulate styling of text in div. things work fine. use jquery ajax load, load new text, , replace old. expected modified css stick, not. reverting unmodified css. make sense?
the question bit vague. please add code make clearer.
here fiddle in have tried demonstrate solution problem understood.
html
<form method="post" action="/echo/html/" ajax="true"> <div class="testblock"> <div class="test"> test 1 </div> <div class="test"> test 2 </div> </div> <button type='submit'>submit</button> </form>
css
.red_div { color: red; }
javascript
$(document).ready(function(e) { $('.test').addclass('red_div'); $("form[ajax=true]").submit(function(e) { e.preventdefault(); var form_url = $(this).attr("action"); var form_method = $(this).attr("method").touppercase(); $.ajax({ url: form_url, type: form_method, cache: false, success: function(){ new_div = $('.testblock') .append('<div class="test">test three</div>'); //new_div.addclass('red_div'); } }); }); });
Comments
Post a Comment