Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


How do you check if an element is empty?



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

Post New Answer

More jQuery Interview Questions

How to check or uncheck all checkboxes using jquery?

0 Answers  


How to add or remove classes to an element in jquery?

0 Answers  


Which sign is used as a shortcut for jQuery?

0 Answers  


What is the difference between $.map and $.grep in jQuery?

0 Answers  


Is jQuery is a JavaScript or JSON library file?

0 Answers  


What is the difference between event.stopPropagation and event.stopImmediatePropagation?

1 Answers  


How can I select 20th div with jquery?

0 Answers  


Can you please explain the difference between javascript and jquery? : jquery mobile

0 Answers  


List browser related issues for jquery?

0 Answers  


How to select class in jquery?

0 Answers  


What is jQuery code to select all links in first paragraph?

0 Answers  


How can you apply a style on an element using jQuery?

0 Answers  


Categories