【发布时间】:2016-06-17 17:00:33
【问题描述】:
我有一个类似于
的字符串 Lorem Ipsum is simply dummy text of the printing and typesetting
industry.<grab> First Item</grab>Lorem Ipsum is simply dummy text of
the printing and typesetting industry.<grab>Second Item</grab>Lorem
Ipsum is simply dummy text of the printing and typesetting
industry.<grab>Third Item</grab>Lorem Ipsum is simply dummy text of
the printing and typesetting industry.
现在我需要获取<grab>....</grab> 标签之间的所有文本并将它们添加到两个数组中。我试过了,但它没有通过
var data = 'Lorem Ipsum is simply dummy text of the printing and typesetting industry.<grab> First Item</grab>Lorem Ipsum is simply dummy text of the printing and typesetting industry.<grab>Second Item</grab>Lorem Ipsum is simply dummy text of the printing and typesetting industry.<grab>Third Item</grab>Lorem Ipsum is simply dummy text of the printing and typesetting industry.';
var array = $('<grab>').map(function() {
return $(this).text();
}).get();
$('body').append(array);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
你能告诉我怎么做吗
【问题讨论】:
标签: javascript jquery