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

What are the browser related issues for jQuery?

0 Answers  


Is there any advantage of using $.ajax() for ajax call against $.get() or $.post()?

1 Answers  


Which program is useful for testing jQuery?

0 Answers  


How do you select element by ID in jQuery?

1 Answers  


How do you get the attribute of an html tag in jquery?

0 Answers  


Explain .live()? : jquery mobile

0 Answers  


How to check if number is numeric while using jquery 1.7+? : jquery mobile

0 Answers  


Explain "beforesend(xhr)" paremeter of jquery ajax method?

0 Answers  


Create a plugin that would add and remove a class on hover.

0 Answers  


What is jQuery?

1 Answers  


When can you use jquery?

0 Answers  


Define type paremeter of jquery ajax method?

0 Answers  


Categories