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?
What is cdn? Explain
How to find all sibling elements in front of the current element using ?
What does $("P") will select?
Can we select a element having a specific class in jquery ?
What is slice() method in jquery?
Why jquery?
What is the goal of cdn and what are the advantages of using cdn?
How to search for descendant elements that match the specified selectors using ?
What is jquery toggle function?
What are selectors in jquery?
Tell me what does $("div") will select? : jquery mobile
How can we show and hide an element via jquery?
How can you add a jquery library in your project?
What is jquery and what are the advantages?