我有几个HTML的结构是这样的:访问内标签文字使用jQuery
<div id="some_id" class="bio">
<h3><img src="some.jpg" alt="alt_text" /><br />
<a name="Name"></a></h3>
<div class="bio_info">
<h3 class="bio_name">NAME TEXT</h3>
<p>BIO TEXT</p>
<div class="add_bio">MORE BIO</div>
</div>
<p><span class="add_bio_toggle">more</span></p>
</div>
,我虽然循环他们,用“这个”变量访问它们。什么是正确的方式来访问我已经大写的文本(名称文本,生物文本,更多的生物)?我一直在尝试变种
var bio.name = $('.bio_info.bio_name', this).html();
无济于事。我错过了什么?
[example code]
//get the national leadership, by column
$('#national_leadership .left_col .bio').each(function(){
//create new object to add to nat_leadership array
var bio = new Object();
bio.id = $(this).attr('id');
bio.name = $('.bio_info', this).find('.bio_name').text();
...
它发现id很好,但返回一个空字符串的名称。
为furthur阅读,,通过这个http://api.jquery.com/text/ – kobe 2011-02-19 04:44:41