A A
RSS

jQuery Wildcard Selector

Sat, Jul 25, 2009

Programming

This post is a reminder for me on how to do wildcard selection in jQuery.  It comes up more than you think and for some reason, I can never remember it.

<div id='pnlUsers'></div>
<div id='pnlMessages'></div>
<div id='pnlStatus'></div>

I can easily hide all the divs up by doing a wildcard selection on elements with an id starting with “pnl”, like this:

$("[id^=pnl]").hide();

You can even narrow it to only divs like this:

$("div[id^=pnl]").hide();

There is another example with even more explanations over here.

Tags: ,

blog comments powered by Disqus
Advertise Here

What I'm Doing...

Yonkly Open Source

Sign up for my newsletter

powered by MailChimp!

Cyber Identity