Reputation: 305
I load an other HTML page to this one and when it's ready I want to change the css of an element from that page. The problem is that the "changing" function triggers before the other page is loaded. So it does nothing.
$("#navbar").load("/other.html");
$("#otherPageElem").css({
"background": "black",
"color": "white"
});
Upvotes: 1
Views: 39
Reputation: 171669
Use the complete callback of load()
$("#navbar").load("/other.html", function(){
// new html exists now
$("#otherPageElem").css({
"background": "black",
"color": "white"
});
});
Upvotes: 1