gpt4 book ai didi

Jquery,获取文本数组()

转载 作者:行者123 更新时间:2023-12-03 21:29:19 27 4
gpt4 key购买 nike

我试图在使用文本函数后获取文本数组,有一个像 ul 列表

<ul>
<li>one
<ul>
<li>one one</li>
<li>one two</li>
</ul>
</li>
</ul>

然后得到类似的东西

['one', 'one one', 'one two']

最佳答案

var array = $('li').map(function(){
return $.trim($(this).text());
}).get();

http://api.jquery.com/map/

演示 fiddle --> http://jsfiddle.net/EC4yq/

关于Jquery,获取文本数组(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16570564/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com