views:

135

answers:

1

HI, I have simple HTML code with some javascript, it looks like:

<html>

<head><script type="text/javascript">...</script></head>

<body>

    <input type="radio" name="radiobutton" value="A" onClick="changeDivContent()">
    <input type="radio" name="radiobutton" value="B" onClick="changeDivContent()">

    <div id="content"></div>

</body>

</html>

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.

Thank you!

+5  A: 

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";
Syntactic
Oh, thank you! It was so easy, for my shame :)
Rob