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 guidelines for an application to follow the principles of progressive enhancement.

0 Answers  


How you will use jquery means requirement needed for using jquery.

0 Answers  


What is the difference between jquery and javascript?

0 Answers  


What is the difference between settimeout() and setinterval() methods?

0 Answers  


Whether C# code behind can be called from jQuery?

0 Answers  


How can an element be checked if it contains a specific class?

0 Answers  


Is it possible to use our own specific character in the place of $ sign in jquery? : jquery mobile

0 Answers  


Explain the difference between onload() and document.ready() function used in jquery?

0 Answers  


Explain jquery connect?

0 Answers  


How do I check if an element is hidden in jQuery?

0 Answers  


What to do to select element having a particular class (".selected")? : jquery mobile

0 Answers  


What is the use of jQuery.data() method?

0 Answers  


Categories