I have the following:
<p class="myClass">This is a paragraph
<div>div within the paragraph</div>
More text in the paragraph
</p>
My jQuery is:
var X = $('div','.myClass');
PRINT(X);
PRINT(X.length);
PRINT(X.selector);
X.selector is: .myClass div, which is what I expected, but X.length=0.
Q: What am I not understanding about context? It also doesn't work if I change it to
var X = $('.myClass div');
This probably isn't the answer to your question, but you shouldn't (maybe even can't) use a 'div' inside a 'p'. You should try using a 'span' inside a 'p'.
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