Answer Posted / 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 |
Post New Answer View All Answers
What is the difference between find and children methods in jquery?
List browser related issues for jquery?
How to read, write and delete cookies in jquery?
Tell me how to check data type of any variable in jquery? : jquery mobile
What the use of $ symbol in jquery.
What are the browser related issues for jQuery?
What is the use of param() method?
Define the use jquery.data method?
What is the difference between the knockout and jquery?
What is the need for jquery? : jQuery Mobile
What is the purpose of fadetoggle() method in jquery?
What is $() in jquery library?
What is queue() in jquery? Use of queue() in jquery?
What is the difference between onload() and document.ready() function used in jquery?
What is the use of jQuery filter?