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

Explain the script build up by jquery?

9264


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

1089


Why html 5 inputs look different across devices and browsers? : jquery mobile

734


What is the minimum setup needed to start using jquery.

805


Tell me which command will give a version of jquery?

724


What were the biggest challenges of getting the 1.7 release out there?

756


Is jquery a library for client scripting or server scripting? : jquery mobile

686


Describe the two types of cdns?

787


Why jquery?

810


How do you install/use jquery in a project. What is the minimum setup needed to start using jquery.

822


How to disable jquery animation? : jquery mobile

776


How can we debug jQuery?

859


Define width() vs css('width')?

725


When can jquery be used?

772


How to resolve conflicts with other libraries?

795