Why isn’t jQuery chaning this element’s style?
I’m loading a navigation bar (navbar.html) into a site using jQuery. When that loads, I want to change the color of the tab on the navbar of the currently loaded page. For example, if the user clicks the “admin” button, the admin page will load, and the navbar button for admin should be highlighted.
The nav bar loads fine, but the button doesn’t change color. This is the code I’m using:
$(function(){
$("#NavBar").load("/navbar.html");
$("#admin_tab").css({'background-color':"#FFF"});
});
I’ve tried using the $.ready()
method, onload
, and others that seem like they should help, but none of those work. If I execute the background-color command in the console, it works fine.