Answers for "jquery if exists element"

22

jquery check if element exists

// Check if an element currently exists
if ($('#element').length) {

}
Posted by: Guest on June-05-2020
4

jquery test div exists

$(document).ready(function() {
    var $myDiv = $('#DivID');

    if ( $myDiv.length){
        //you can now reuse  $myDiv here, without having to select it again.
    }


});
Posted by: Guest on March-27-2020
0

jquery if element appears

setInterval(function() {
    $('.my-element-class:not(.appeared)')
        .addClass('appeared')
        .each(function() {
            console.log("here I am!")
        });
}, 250);
Posted by: Guest on August-03-2021
-2

jquery check if element still exists

$(function() {
    var $button = $(".the_button");
    alert (isStale($button));
    $button.remove();
    alert (isStale($button));
});
    
function isStale($elem)
{
    return $elem.closest("body").length > 0;
};
Posted by: Guest on April-17-2020

Code answers related to "jquery if exists element"

Code answers related to "Javascript"

Browse Popular Code Answers by Language