Change span text? [duplicate]

。_饼干妹妹 提交于 2020-05-09 20:02:39

问题


Possible Duplicate:
How do I change the text of a span element in javascript

Well, I've searched a lot for the answer to this, but still I couldn't find it. What I did find didn't work.

What I'm trying to do is, basically, using JavaScript: At the browser's bar, not via Greasemonkey or something else, edit a span's text .

This' the span that contains the text I want to edit:

<span id="serverTime">5:46:40</span>

The time within is just random, don't pay attention to it, it's what I want to edit using javascript..

I'm a newbie so yeah :\


回答1:


document.getElementById("serverTime").innerHTML = ...;



回答2:


Replace whatever is in the address bar with this:

javascript:document.getElementById('serverTime').innerHTML='[text here]';

Example.



来源:https://stackoverflow.com/questions/8177215/change-span-text

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!