Javascript 在DOM中查找具有特定类名的最后一个跨度 9喜欢 Abc 你好,你好吗 2012年6月12日 7小时前 9喜欢 Abc 你好,你好吗 2012年6月12日 7小时前 9喜欢 Abc 你好,你好吗 2012年6月12日 7小时前
我有如上所述的html结构。。因此,从$('.comments\u container')开始,如何使用类“comment\u time”遍历到DOM中的最后一个跨度。我们将不胜感激 可以使用children()进行遍历。但我想知道有没有更简单的方法可以使用选择器:Javascript 在DOM中查找具有特定类名的最后一个跨度 9喜欢 Abc 你好,你好吗 2012年6月12日 7小时前 9喜欢 Abc 你好,你好吗 2012年6月12日 7小时前 9喜欢 Abc 你好,你好吗 2012年6月12日 7小时前,javascript,jquery,Javascript,Jquery,我有如上所述的html结构。。因此,从$('.comments\u container')开始,如何使用类“comment\u time”遍历到DOM中的最后一个跨度。我们将不胜感激 可以使用children()进行遍历。但我想知道有没有更简单的方法可以使用选择器: <div class="comments_container clearfix"> <hr /> <ul class="comment_struct"> <li class
<div class="comments_container clearfix">
<hr />
<ul class="comment_struct">
<li class="commenter_pic">
<img src="images/im.jpg" alt="picture"/>
<span class="button blue square likes">9 Likes</span>
</li>
<li class="comment_data">
<ul class="post_info_options">
<li class="commenter_name">Abc</li>
<li class="comment"><p>hello how are you doing</p></li>
<li class="time">
<span class="comment_time">12 June 2012<>
<span class="time_elapsed">7 hours ago</span>
</li>
<li class="options">
<span><a href="#">Once More</a></span>
<span><a href="#">Comment</a></span>
<span><a href="#" class="comment_like">Like</a></span>
</li>
<li>
</li>
</ul>
</li>
<li class="delete_comment"><img src="images/Cancel.png" alt="delete_post"/></li>
</ul>
<br/>
<ul class="comment_struct">
<li class="commenter_pic">
<img src="images/im.jpg" alt="picture"/>
<span class="button blue square likes">9 Likes</span>
</li>
<li class="comment_data">
<ul class="post_info_options">
<li class="commenter_name">Abc</li>
<li class="comment"><p>hello how are you doing</p></li>
<li class="time">
<span class="comment_time">12 June 2012<>
<span class="time_elapsed">7 hours ago</span>
</li>
<li class="options">
<span><a href="#">Once More</a></span>
<span><a href="#">Comment</a></span>
<span><a href="#" class="comment_like">Like</a></span>
</li>
<li>
</li>
</ul>
</li>
<li class="delete_comment"><img src="images/Cancel.png" alt="delete_post"/></li>
</ul>
<br/>
<ul class="comment_struct">
<li class="commenter_pic">
<img src="images/im.jpg" alt="picture"/>
<span class="button blue square likes">9 Likes</span>
</li>
<li class="comment_data">
<ul class="post_info_options">
<li class="commenter_name">Abc</li>
<li class="comment"><p>hello how are you doing</p></li>
<li class="time">
<span class="comment_time">12 June 2012<>
<span class="time_elapsed">7 hours ago</span>
</li>
<li class="options">
<span><a href="#">Once More</a></span>
<span><a href="#">Comment</a></span>
<span><a href="#" class="comment_like">Like</a></span>
</li>
<li>
</li>
</ul>
</li>
<li class="delete_comment"><img src="images/Cancel.png" alt="delete_post"/></li>
</ul>
<br/>
您可以使用选择器:
<div class="comments_container clearfix">
<hr />
<ul class="comment_struct">
<li class="commenter_pic">
<img src="images/im.jpg" alt="picture"/>
<span class="button blue square likes">9 Likes</span>
</li>
<li class="comment_data">
<ul class="post_info_options">
<li class="commenter_name">Abc</li>
<li class="comment"><p>hello how are you doing</p></li>
<li class="time">
<span class="comment_time">12 June 2012<>
<span class="time_elapsed">7 hours ago</span>
</li>
<li class="options">
<span><a href="#">Once More</a></span>
<span><a href="#">Comment</a></span>
<span><a href="#" class="comment_like">Like</a></span>
</li>
<li>
</li>
</ul>
</li>
<li class="delete_comment"><img src="images/Cancel.png" alt="delete_post"/></li>
</ul>
<br/>
<ul class="comment_struct">
<li class="commenter_pic">
<img src="images/im.jpg" alt="picture"/>
<span class="button blue square likes">9 Likes</span>
</li>
<li class="comment_data">
<ul class="post_info_options">
<li class="commenter_name">Abc</li>
<li class="comment"><p>hello how are you doing</p></li>
<li class="time">
<span class="comment_time">12 June 2012<>
<span class="time_elapsed">7 hours ago</span>
</li>
<li class="options">
<span><a href="#">Once More</a></span>
<span><a href="#">Comment</a></span>
<span><a href="#" class="comment_like">Like</a></span>
</li>
<li>
</li>
</ul>
</li>
<li class="delete_comment"><img src="images/Cancel.png" alt="delete_post"/></li>
</ul>
<br/>
<ul class="comment_struct">
<li class="commenter_pic">
<img src="images/im.jpg" alt="picture"/>
<span class="button blue square likes">9 Likes</span>
</li>
<li class="comment_data">
<ul class="post_info_options">
<li class="commenter_name">Abc</li>
<li class="comment"><p>hello how are you doing</p></li>
<li class="time">
<span class="comment_time">12 June 2012<>
<span class="time_elapsed">7 hours ago</span>
</li>
<li class="options">
<span><a href="#">Once More</a></span>
<span><a href="#">Comment</a></span>
<span><a href="#" class="comment_like">Like</a></span>
</li>
<li>
</li>
</ul>
</li>
<li class="delete_comment"><img src="images/Cancel.png" alt="delete_post"/></li>
</ul>
<br/>
您正在查找$('comments\u container comment\u time')
?您是指DOM中的最后一个“.comment\u time”还是“.comments\u container”中的最后一个“.comments\u time”?不管是哪种方式,我都建议花几分钟阅读——它给出了所有jQuery方法和选择器的列表,每个方法和选择器都有一句话的描述。(然后,您可以点击查看您感兴趣的任何内容的完整详细信息。)您正在查找$('comments\u container comment\u time')
?您是指DOM中的最后一个“.comment\u time”还是“.comments\u container”中的最后一个“.comments\u time”?不管是哪种方式,我都建议花几分钟阅读——它给出了所有jQuery方法和选择器的列表,每个方法和选择器都有一句话的描述。(然后,您可以单击以获取您感兴趣的任何项目的完整详细信息。)