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?

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


Please Help Members By Posting Answers For Below Questions

How to disable cut,copy and paste in TextBox using jQuery?

969


What is cdn? Explain

796


How to find all sibling elements in front of the current element using ?

853


What does $("P") will select?

863


Can we select a element having a specific class in jquery ?

831


What is slice() method in jquery?

836


Why jquery?

873


What is the goal of cdn and what are the advantages of using cdn?

795


How to search for descendant elements that match the specified selectors using ?

787


What is jquery toggle function?

882


What are selectors in jquery?

876


Tell me what does $("div") will select? : jquery mobile

801


How can we show and hide an element via jquery?

796


How can you add a jquery library in your project?

764


What is jquery and what are the advantages?

843