jQuery class selectors with nested div's
Posted
by
mboles57
on Stack Overflow
See other posts from Stack Overflow
or by mboles57
Published on 2012-11-28T16:49:32Z
Indexed on
2012/11/28
17:04 UTC
Read the original article
Hit count: 241
jQuery
This is part of some HTML from which I need to retrieve a piece of data. The HTML is assigned to a variable called fullDescription.
<p>testing</p>
<div class="field field-type-text field-field-video-short-desc">
<div class="field-label">Short Description: </div>
<div class="field-items">
<div class="field-item odd">
Demonstrates the basics of using the Content section of App Cloud Studio
</div>
</div>
</div>
<div class="field field-type-text field-field-video-id">
<div class="field-label">Video ID: </div>
<div class="field-items">
<div class="field-item odd">
1251462871001
</div>
</div>
</div>
I wish to retrieve the video ID number (1251462871001). I was thinking something like this:
var videoID = $(fullDescription).find(".field.field-type-text.field-field-video-id").find(".field-item.odd").html();
Although it does not generate any syntax errors, it does not retrieve the number.
Thanks for helping out a jQuery noob!
-Matt
© Stack Overflow or respective owner