How do I change the text of a span element using JavaScript?

后端 未结 13 949
悲&欢浪女
悲&欢浪女 2020-11-22 09:21

If I have a span, say:

 hereismytext 

How do I use JavaScript to change "hereism

13条回答
  •  故里飘歌
    2020-11-22 10:03

    Like in other answer, innerHTML and innerText are not recommended, it's better use textContent. This attribute is well supported, you can check it this: http://caniuse.com/#search=textContent

提交回复
热议问题