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
Explain the script build up by jquery?
What is the difference between onload() and document.ready() function used in jquery?
Why html 5 inputs look different across devices and browsers? : jquery mobile
What is the minimum setup needed to start using jquery.
Tell me which command will give a version of jquery?
What were the biggest challenges of getting the 1.7 release out there?
Is jquery a library for client scripting or server scripting? : jquery mobile
Describe the two types of cdns?
Why jquery?
How do you install/use jquery in a project. What is the minimum setup needed to start using jquery.
How to disable jquery animation? : jquery mobile
How can we debug jQuery?
Define width() vs css('width')?
When can jquery be used?
How to resolve conflicts with other libraries?