Saved X
Google login
SignUp with Email
X

Jquery check if element still exists

theindreshverma ( Edited  Sep 29, 02:44 pm )
Login

Jquery .length method check element exist or not.

<html>
<head>
    <title>Jquery check if element still exists</title>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
</head>
<body>

<h1>Jquery check if element still exists</h1>

<p id="el">This is paragraph tag.</p>

<button id="button">Check element</button>

<script>
$("#button").click(function () {
    if($('#el').length) {
        alert("Element exists");
    }
    else {
    	alert("Element not exists");
    }	
});
</script>

</body>
</html>

Sourcecode Tags

More Sourcecodes

More Sourcecodes