使用jQuery向超链接内的文本添加span标记
如何将跨度标记添加到超链接内的文本 现在,我正在使用以下方法将现有文本更改为其他文本:使用jQuery向超链接内的文本添加span标记,jquery,Jquery,如何将跨度标记添加到超链接内的文本 现在,我正在使用以下方法将现有文本更改为其他文本: $(document).ready(function() { $("a:contains('text')").text('new-text') }); 解析链接时,我需要该链接如下所示: <a href="/xxx.aspx">new-text<span class="someclass">some other text</span></a> 所以我需要
$(document).ready(function() {
$("a:contains('text')").text('new-text')
});
解析链接时,我需要该链接如下所示:
<a href="/xxx.aspx">new-text<span class="someclass">some other text</span></a>
所以我需要在
有什么想法吗?$(“a:contains('text'))
$("a:contains('text')")
.text('new-text')
.append($('<span></span>')
.addClass('someclass')
.text('some other text')
)
;
.text(“新文本”)
.append($('')
.addClass('someclass')
.text(“其他一些文本”)
)
;
$(“a:contains('text'))
.text(“新文本”)
.append($('')
.addClass('someclass')
.text(“其他一些文本”)
)
;
您可以使用html()
方法添加标记:
$(document).ready(function() {
$("a:contains('text')").html('new-text<span class="someclass">some other text</span>')
});
$(文档).ready(函数(){
$(“a:contains('text')”).html('new-textsomethertext'))
});
您可以使用html()
方法添加标记:
$(document).ready(function() {
$("a:contains('text')").html('new-text<span class="someclass">some other text</span>')
});
$(文档).ready(函数(){
$(“a:contains('text')”).html('new-textsomethertext'))
});
我要选这个。谢谢我要用这个。谢谢