我有以下标记来呈现链接:-
<a id="forum0-NewPostLink" class="ms-textXLarge ms-heroCommandLink" title="add new discussion" href="/Lists/erwerwerwerew/NewForm.aspx?Source=http%3A%2F%2F%2FSitePages%2FHome%2Easpx">
<span class="ms-list-addnew-imgSpan20">
<img class="ms-list-addnew-img20" src="/_layouts/15/images/spcommon.png?rev=23">
</span>
<span>new discussion</span>
</a>
现在我想将“新讨论”替换为“新元素”。那么任何人都可以告诉我如何使用 CSS 或 javascript 做到这一点吗?
最佳答案
用 jQuery 可以使用:
$('#forum0-NewPostLink span:last').text('My new text');
如果这需要更加动态,您将需要提供更多详细信息
CSS 方法:
#forum0-NewPostLink span:last-of-type {
display:none
}
#forum0-NewPostLink:first-of-type:after{
display:block;
content:'New text'
}
关于javascript - 如何替换链接名称文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31953276/