【发布时间】:2009-10-12 21:33:09
【问题描述】:
我有一个字符串,其中包含文本和一些<a> 标签;我想知道如何从变量中选择一个标签并循环它。我尝试了以下方法,但没有成功:
var text = `some string here with <a href="#link">http:something.com</a> more string and more links also`;
$('a', text).each(function() {
var string = $(this).html();
$(this).html(string.substring(0, length-1)+(string.length > length ? end : ''));
});
【问题讨论】:
标签: javascript jquery selector