本文介绍了遍历JQuery中的跨度组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
<td style="display:none;">
<span class="runId">4</span><span class="processName">Get End-Of-Day Reuters Feed Rates</span>
<span class="runId">130</span><span class="processName">Get End-Of-Day Bloomberg Feed Rates</span>
<span class="runId">133</span><span class="processName">CapVolsCalibration AllCurrencies EOD</span>
<span class="runId">228</span><span class="processName">GBP Basis Adjustment</span>
</td>
伙计们,我将如何在JQuery中循环遍历此<td>
,对于每组两个span
元素,分别获取runId
和processName
元素的text()
.
Hey guys, how would I loop through this <td>
in JQuery and for each group of two span
elements, get the text()
of the runId
and the processName
elements.
推荐答案
对紧急情况进行功能编程:
Functional programming to the rescue:
var data = $td.children('span.runId').map(function() {
return {runId: $(this).text(), processName: $(this).next().text()};
}).get();
构造数据的方式.
这篇关于遍历JQuery中的跨度组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!