Reputation: 2341
I am trying to add some functionality to my posts/new page when it loads, using jQuery. Is it possible to specifically listen to the jQuery page load event for any particular page?
Upvotes: 2
Views: 6391
Reputation: 69915
Try this
if($("#elementId").length > 0){
$(document).ready(function(){
});
}
You can also use it is same as ready method.
$(function(){
});
Upvotes: 5
Reputation: 71939
Yes:
$(document).ready(function(){
// Your code here
});
OR simply:
$(function(){
// Your code here
});
Upvotes: 1