如何更改ato中的所有文本
继续阅读
使用jquery
<div class="post-read">
<a href="http://www.google.com">Read More</a>
</div>
Run Code Online (Sandbox Code Playgroud)
ale*_*lex 31
在文档就绪处理程序($(fn))中使用jQuery做它...
$('.post-read a').text('continue reading');
Run Code Online (Sandbox Code Playgroud)
为了它,这里是没有jQuery如何做到这一点....
var anchor = document.getElementsByClassName('post-read')[0].getElementsByTagName('a')[0],
textProperty;
if (anchor.textContent) {
textProperty = 'textContent';
} else if (anchor.innerText) {
textProperty = 'innerText';
}
anchor[textProperty] = 'continue reading';
Run Code Online (Sandbox Code Playgroud)
这对你的HTML片段很有用,但它不太通用.
如果你不关心设置innerText属性,你可以使用...
anchor.textContent = anchor.innerText = 'continue reading';
Run Code Online (Sandbox Code Playgroud)
我不会推荐它.
| 归档时间: |
|
| 查看次数: |
32521 次 |
| 最近记录: |