如何替换链接名称文本(how to replace a link name text)

我有以下标记来呈现链接: -

<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>

现在我想将“新讨论”替换为“新项目”。 所以任何人都可以adivce如何使用CSS或JavaScript做到这一点?

I have the following markup to render a link :-

<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>

now i want to replace the "new discussion" to be "new item". so can anyone adivce how i can do so using CSS or javascript ?

最满意答案

如果我正确地得到了你,你可以用普通的javascript来做到这一点,但这并不是一个好主意。

var a = document.getElementById('forum0-NewPostLink'); var b = a.getElementsByTagName('span'); var arr = [].slice.call(b); arr.pop().innerHTML = 'new Item';

If I get you correctly, you can do it like this with plain javascript, but this isn't a good aproach over all..

var a = document.getElementById('forum0-NewPostLink'); var b = a.getElementsByTagName('span'); var arr = [].slice.call(b); arr.pop().innerHTML = 'new Item';

更多推荐