Oleksandr IY
Oleksandr IY

Reputation: 3146

attribute selector doesn't work

I try to select element by attribute with code below

$('dt[data-panel="2"] h2').html();

but this doesn't work for

<dl>
    <dt data-panel="panel-2">
        <h2 class="delta expandable">Text</h2>
    </dt>
</dl>

am I missing something?

fiddle is here http://jsfiddle.net/u1offsyw/

Upvotes: 1

Views: 41

Answers (1)

Rory McCrossan
Rory McCrossan

Reputation: 337714

The value of the attribute is panel-2, not just 2, hence your selector needs to be:

$('dt[data-panel="panel-2"] h2').html(); 

Updated fiddle

Upvotes: 2

Related Questions