Thursday, July 4, 2013

How to find whether an element is there in jquery

<html>
<head>
</head>
<body>
<input id="fname" name="" value="hi" type="text"/>
</body>
</html>

jQuery.fn.exists = function(){return this.length>0;}

Example
if ($('#fname').exists()) {
   
    alert('Yes Its There');
}else{

    alert('No Its NOT There');
}

No comments:

Post a Comment