添加javascript innerHTML而不是替换 [英] javascript innerHTML adding instead of replacing
本文介绍了添加javascript innerHTML而不是替换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
快速提问,我知道我们可以更改
quick question, i know we can change the content of a
< div id =whatEverId > hello one< div>
使用:
document.getElementById("whatEverId").innerHTML="hello two";
现在,有没有办法我可以添加东西到div替换它???
所以我可以获得
now, is there a way I can ADD stuff to the div instead of replacing it??? so i can get
< div id =whatEverId>你好一个你好两个< div>
(当然使用类似的东西)
推荐答案
<div id="whatever">hello one</div>
<script>
document.getElementById("whatever").innerHTML += " hello two";
</script>
这篇关于添加javascript innerHTML而不是替换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文