HTML/Javascript change div content
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have simple HTML code with some javascript, it looks like: I just wanted to be able change div's content (it's inner html) with selecting one of "A" or "B" radio buttons, but div#content does not have javascript attribute "value", so I am asking how it can be done. 回答1: Assuming you're not using jQuery or some other library that makes this sort of thing easier for you, you can just use the element's innerHTML property. document.getElementById("content").innerHTML = "whatever"; 回答2: $('#content').html('whatever'); 回答3: Get the id of the div