JQuery attribute for aria attribute containing value

In the HTML structure:

<div class="someclass" tabindex="0" aria-describedby="my-specified-action my-one-name">
<div class="someclass" tabindex="1" aria-describedby="my-specified-action my-two-name">
<div class="someclass" tabindex="2" aria-describedby="my-specified-action my-three-name">
<div class="someclass" tabindex="3" aria-describedby="my-specified-action my-four-name">
<div class="someclass" tabindex="3" aria-describedby="my-specified-action my-five-name">

I need to hide all elements that have an attribute aria-describedbycontaining my value (for example, four), but leave all the others untouched.

jQuery('div[aria-describedby*="four"]').hide()

of course if i do:

jQuery('div:not([aria-describedby*="four"])').hide()

he will hide ALL elements (also those that contain my purpose ..)

for some reason, this does not work for me ..

jQuery('div:not([aria-describedby^="four"])').hide()

what am I doing wrong?

+3
source share
1 answer

Your problem is not with the attribute selector, it is the target element selector.

div, aria-describedby four, , , . , div someclass,

jQuery('div.someclass:not([aria-describedby*="four"])').hide()

: Fiddle

+4

All Articles