I can’t use:
$('div:empty')
because the div might have empty spaces in it. I want to remove it if it has nothing or nothing but empty spaces.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This will return all
divelements with no text apart from blank spaces (or other characters removed by.trimsuch as new line characters):Update – based on comments
If any of the
divelements in question have child elements which do not contain text (for example,imgelements) then the above method will include them in the set of “empty” elements. To exclude them, you can use the following: