在jQuery中获取标签内部的值? [英] get value of inside a tag with jQuery.?
本文介绍了在jQuery中获取标签内部的值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
jQuery如何在标记b
中获取值?
How can by jQuery get value inside tag b
?
<span>
<b>hi_1</b>
<b>hi_2</b>
<b>hi_3</b>
<b>hi_4</b>
<span>
我想要使用jQuery的输出:hi_1, hi_2, hi_3, hi_4
请在 jsfiddle 中给我示例.
I want this output with jQuery: hi_1, hi_2, hi_3, hi_4
Please give me example in jsfiddle.
推荐答案
您是否正在寻找类似的东西?
Are you looking for something like this?
$(document).ready(function() {
var textArr = [];
$('span b').each(function() {
textArr.push($(this).text());
});
alert(textArr.join(', '));
});
这篇关于在jQuery中获取标签内部的值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文