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 |
Which program is useful for testing jQuery?
Is it possible to use jquery to make ajax request? : jquery mobile
What are the different ways of using $.connect function in jquery?
Difference between $(this) and 'this' in jQuery?
How to executed jquery selectors? : jquery mobile
How to include jquery library in asp.net project?
How do you get the attribute of an html tag in jquery?
Tell me how to disable jquery animation? : jquery mobile
What is the name of jquery method used for an asynchronous http request?
Explain the difference between jquery-x.x.x.js and jquery.x.x.x min.js?
What is get()? : jquery mobile
Which one is more efficient, document.getElementbyId( "myId") or $("#myId)?