rookieRailer
rookieRailer

Reputation: 2341

listen for jQuery load event for a certain page

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: 6389

Answers (2)

ShankarSangoli
ShankarSangoli

Reputation: 69905

Try this

if($("#elementId").length > 0){
    $(document).ready(function(){

    });
}

You can also use it is same as ready method.

$(function(){

});

Upvotes: 5

bfavaretto
bfavaretto

Reputation: 71918

Yes:

$(document).ready(function(){
    // Your code here
});

OR simply:

$(function(){
    // Your code here
});

Upvotes: 1

Related Questions