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 term method chaining? : jQuery Mobile
Define data paremeter of jquery ajax method?
How to revert the most recent ‘destructive’ operation, changing the set of matched elements to its previous state using ?
How do I check if the DOM is ready?
What are the advantage of using cdn? : jquery mobile
What does the jQuery migrate function do?
What is ajax and how it works?
What are the the two types of cdns?
Which one is more efficient, document.getElementbyId( "myId") or $("#myId)?
Explain .live()? : jquery mobile
Tell me which program is useful for testing jquery?
How to write browser specific code using jquery? : jquery mobile
Suppose if you have a server control(asp.net server control, button) and on the click of button you want to call a jquery function, so tell me how you will call a jquery function without postback?
What is the latest version of jquery?
What is queue() in jquery?