javascript - How do I get jquery to select classes in html which has been loaded using client.open -


in html document have code

var client = new xmlhttprequest(); client.open('get', '(url)example.txt'); client.onreadystatechange = function() {        var theblog = client.responsetext;        $("#bloglocation").html(theblog); } client.send(); }); 

in loaded html have

    <p class="example">example</p> 

later on in file use jquery change color of elements in class example.

    $('.example).css({"background-color" : "yellow"}); 

the jquery works elements class not in loaded html. how can work class in loaded html.

you using jquery, use jquery:

$.get('example.txt').done(function(data) {     $("#bloglocation").html(data); }); 

but need set background color after data has loaded:

$.get('example.txt').done(function(data) {     $("#bloglocation").html(data);     $("#bloglocation .example").css({"background-color" : "yellow"}); }); 

Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -