Reputation: 837
I have a div like this
<div id="test"></div>
I want to find if there are any text inside the div. how can I find it with jQuery?
Upvotes: 1
Views: 49
Reputation: 67187
You can use :empty
selector along with .is()
function to achieve what you want.
Try,
if($('#test').is(':empty')){
//Its empty go ahead
}
Or
if($.trim($("#test").text()) === ""){
//Its empty go ahead
}
Upvotes: 3