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 eq() and get() methods in jQuery?
Define type paremeter of jquery ajax method?
What is the difference between parent() and parents() methods in jQuery?
explain bind() vs live() vs delegate() methods in jquery
What is the difference between $('div') and $('<div/>') in jQuery?
In jquery, what is the meaning of toggle?
Tell me how to disable jquery animation? : jquery mobile
Define slidetoggle() effect?
How to include jQuery in ASP.Net project?
How can you add a jquery library in your project?
Is jquery a library for client scripting or server scripting? : jquery mobile
What is the difference between size and length of jQuery?