jQuery included with WordPress is in compatibility mode. To avoid conflicts with other libraries we can not use the $
shortcut for jQuery
. To use the $
sign we use:
jQuery(document).ready(function($) {
$('#myid').css({'background': 'black', 'color': 'white'});
});
This works. But my question is how to do the same with window load. I have been facing this problem since last few projects. So, thought better to make the concept clear.
jQuery(window).load(function($) {
$('#myid').css({'background': 'black', 'color': 'white'});
});
With this I get an error that says : $ is not a function
. So, I'm unable to use $
inside of the window.load
code block. Can anyone help how I can use the $
shortcut inside window.load
?