html 看起来像这样:
<td class="desc-col">
Good Stuff
<div class="options">
<ul>
<li>
<em>Price</em>
$800.00
</li>
</ul>
</div>
</td>
<td class="desc-col">
Awesome Stuff
<div class="options">
<ul>
<li>
<em>Price</em>
$200.00
</li>
</ul>
</div>
</td>
Run Code Online (Sandbox Code Playgroud)
我想在 td 中获取文本但不想要任何其他内容。我试过这个,但它不仅仅得到 td:
Array = [];
$("td.desc-col").each(function() {
Array.push( $(this).text());});
Run Code Online (Sandbox Code Playgroud)
我怎么会简单地得到这个:
["Good Stuff","Awesome Stuff"]
Run Code Online (Sandbox Code Playgroud) 使用数组,我如何将一个字符附加到数组中的每个元素?我想在每个元素后添加字符串":",然后打印结果.
var a = [54375, 54376, 54377, 54378, 54379, 54380, 54381, 54382, 54383, 54384, 54385, 54386, 54387, 54388, 54389, 54390, 54391, 54392, 54393, 54394, 54395, 54396, 54397, 54400, 54402, 54403, 54405, 54407, 54408];
Run Code Online (Sandbox Code Playgroud)
例如:54375:54376:54377