
12-10-2007, 01:32 AM
|
|
New kid on the block
|
|
Join Date: Oct 2007
Location: Malaysia
Posts: 2
Rep Power: 0
|
|
Help! InnerHTML Problem (javascript)
Hi, I'm having some problem with innerHTML. I was able to enter content into innerHTML with javascript. But how do I clear the innerHTML content and enter another new content? Below is the example problem
--------------------------------------------------------------------------
<div id="testing"></div>
<script type="text/javascript">
function show1() {
document.getElementById('testing').innerHTML = "Hello World";
}
function show2() {
document.getElementById('testing').innerHTML = "Goodbye World";
}
</script>
<input type="button" value="show1" onmousedown="javascript:show1();" />
<input type="button" value="show1" onmousedown="javascript:show2();" />
--------------------------------------------------------------------------
When I try it, it ended up showing "Hello WorldGoodby World" if I press "show1" then press "show2". How can I clear the content before enter new content in innerHTML?
|