I want to hide “select” itself using jquery if there is no “option” append with it.
Share
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.
Assuming I’ve understood your question correctly, you can use the
:emptyselector to findselectelements with no children:You may want to consider another answer if you have empty
<optgroup>element children within theselect(or any other non-option element children), as:emptywill consider theselectto not be empty (it has children, just nooptionchildren).Also, as
:emptylooks for elements with no child nodes (not just elements), text nodes are included (but note that comment nodes are ignored). That means it would only matchselectelements like this: