The is() method is used to check if one of the selected elements matches to the selector element. This method can be used on this element to test if it is empty by using “:empty” selector. The “:empty” selector is used to select all the elements that have no children.
Use the childNodes property to check if a div element is empty. The childNodes property returns a NodeList of the element's child nodes, including elements, text nodes and comments. If the property returns a value of 0 , then the div is empty.
The empty() method is an inbuilt method in jQuery which is used to remove all child nodes and its content for the selected elements. Parameter: This method does not accept any parameter. Return Value: This method returns the selected element with the specified changes made by empty() method.
$('form input[name="birthDate"])'). blur(function () { var dob = $("#dob"). val(); if(dob == "") { $("#dobAlert").
Use the s.length property.
if(s.length == 0) {
...
}
[edit] size() deprecated in jquery 1.8 http://api.jquery.com/size/
if($("#something").length > 0 ){
// Element found
}
else{
// No element found
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With