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 |
How does caching helps and how to use caching in jQuery?
How do you update ajax response with id " resilts"?
What are features of jquery or what can be done using jquery?
Which are the fastest selectors in jquery? : jquery mobile
What is the difference between settimeout() and setinterval() methods?
Mention the advantages of cdn? : jQuery Mobile
What is jQuery?
Can we select a element having a specific class in jquery ?
What is the difference between onload() and document.ready()?
What are all the ways to include jQuery in a page?
How to divide a page into parts using jquery mobile? : jquery mobile
Explain the advantages of jquery?