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 term method chaining? : jQuery Mobile

753


Define data paremeter of jquery ajax method?

786


How to revert the most recent ‘destructive’ operation, changing the set of matched elements to its previous state using ?

791


How do I check if the DOM is ready?

839


What are the advantage of using cdn? : jquery mobile

825


What does the jQuery migrate function do?

834


What is ajax and how it works?

816


What are the the two types of cdns?

828


Which one is more efficient, document.getElementbyId( "myId") or $("#myId)?

833


Explain .live()? : jquery mobile

799


Tell me which program is useful for testing jquery?

734


How to write browser specific code using jquery? : jquery mobile

857


Suppose if you have a server control(asp.net server control, button) and on the click of button you want to call a jquery function, so tell me how you will call a jquery function without postback?

834


What is the latest version of jquery?

871


What is queue() in jquery?

862