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 are the browser related issues for jQuery?
Is there any advantage of using $.ajax() for ajax call against $.get() or $.post()?
Which program is useful for testing jQuery?
How do you select element by ID in jQuery?
How do you get the attribute of an html tag in jquery?
Explain .live()? : jquery mobile
How to check if number is numeric while using jquery 1.7+? : jquery mobile
Explain "beforesend(xhr)" paremeter of jquery ajax method?
Create a plugin that would add and remove a class on hover.
What is jQuery?
When can you use jquery?
Define type paremeter of jquery ajax method?