how to check whether an element exists using jQuery

To improve the software's robustness. you need to ensure it's part of DOM before using a HTML element .

use selector.length method to do the check.

if ($("#selector").length) {
    // element exists
}

Try now

date2019-04-16 08:35:50 From:www.jquerypluginhub.com Author:JPH
Related Tags:
Comments

Leave a Reply

Your email address will not be published. Required fields are marked *