I have something like this
<div id="div1">
<span class="label">some text</span>
</div>
<div id="div2">
<span class="label">some text</span>
</div>
I want to select a given span through id and then throu class. Something like #div1.label
or #div2.span
but this way doesn't work. How I can?
Use a space to indicate the element is a child:
$('#div1 .label');
$('#div2 span');
$('#div2 span.label');
#div1.label
would select an element with id div1 and a class of label.
You could do
$("#div1 span.label")
if you use #div1.label
you're actually selecting an element with id div1
AND having the class label
.
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