Alex Rivera | Logout

How to wait until an element exists?

Asked 2011-04-02T18:32:18.133
557

I'm working on an Extension in Chrome, and I'm wondering: how do I find out when an element comes into existence? Using plain JavaScript, with an interval that checks until an element exists, or does jQuery have some easy way to do this?

Edit
Report

1 Answer

26

You can do

$('#yourelement').ready(function() {

});

Please note that this will only work if the element is present in the DOM when being requested from the server. If the element is being dynamically added via JavaScript, it will not work and you may need to look at the other answers.

answered 2011-04-02T18:43:54.843

Your Answer