Say I have the following:
<div id="hellokat"></div>
<div id="hellodog"></div>
<div id="byekat"></div>
<div id="byedog"></div>
I know I can select divs individually with $('#hellokat') and $('hellodog'), but I want to select all divs containing "hello" at the beginning of their ids at the same time.
Wildcards in jQuery selectors
Simply use regular expressions in selectors:
$("div[id^=hello]").hide();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With