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

What is the difference between find and children methods in jquery?

1200


List browser related issues for jquery?

768


How to read, write and delete cookies in jquery?

757


Tell me how to check data type of any variable in jquery? : jquery mobile

765


What the use of $ symbol in jquery.

805


What are the browser related issues for jQuery?

780


What is the use of param() method?

907


Define the use jquery.data method?

816


What is the difference between the knockout and jquery?

805


What is the need for jquery? : jQuery Mobile

881


What is the purpose of fadetoggle() method in jquery?

768


What is $() in jquery library?

865


What is queue() in jquery? Use of queue() in jquery?

790


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

1151


What is the use of jQuery filter?

782