How do you check if an element is empty?
Answer / chaitanya
There are 2 ways to check if element is empty or not. We can check using ":empty" selector.
Hide Copy Code
$(document).ready(function(){
if ($('#element').is(':empty')){
//Element is empty
}
});
And the second way is using the "$.trim()" method.
Hide Copy Code
$(document).ready(function(){
if($.trim($('#element').html())=='') {
//Element is empty
}
});
Is This Answer Correct ? | 0 Yes | 0 No |
What is the difference between size and length of jQuery?
List the advantages of jquery?
Define jquery filter?
How do you add an HTML element in DOM tree?
How do you check if an element exists or not in jQuery?
How does jquery mobile theming work? : jquery mobile
How to use jquery library in our asp.net project?
Explain the difference between javascript and jquery? : jquery mobile
What is the difference between prop() and attr() in jquery?
How to create clone of any object using jQuery?
Tell me can we have multiple document.ready() function on the same page? : jquery mobile
What are all the ways to include jQuery in a page?