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
How to disable cut,copy and paste in TextBox using jQuery?
How to resolve conflicts with other libraries?
What is the use of css() method in jquery?
Explain the difference between .js and .min.js?
How can we give face effect in jquery?
In what scenarios jQuery can be used?
How to call a method inside code-behind using jquery?
How to get the style property of an element using ?
Is vanilla js faster than jquery?
Can you write a code to select all links inside the paragraph?
How to disable/enable an element in jquery?
What is the need for jquery? : jQuery Mobile
Is jquery a w3c standard? : jquery mobile
Explain type paremeter of jquery ajax method?
Tell me which command will give a version of jquery?