Yes the
<Input type='Button'>,
suggested by Mike made the difference.
Edited code below
This is a follow on question to
HTML5, div, hidden, show on click
I'm trying to get a working example, based on the last answer in that post.
Still confused about how I should have posted this...Should I have posted my question as a 'comment' in response to original post I followed? Or do I create a posting when it's a new (I think) question? There's also the other posting that Mike recommended, that cleared up the problem.
I'd like to be able to 1) add the lightbulb image- 'WebVuCoolOldBulb-2.jpg' to the DOM (did I use 'DOM' right?)
and ALSO understand how to 2) Replace my cactus picture - img/WebVuHedgehogCalicoCactusInBloomJoshuaTreeLaurelShimer.jpg with the picture of the lightbulb - WebVuCoolOldBulb-2.jp
The code runs clean with no errors from 'Show Error Console' in Safari. But it does not add the light bulb image
<html>
<body>
<form>
<img id="cactusPhoto"
src="img/WebVuHedgehogCalicoCactusInBloomJoshuaTreeLaurelShimer.jpg"
alt="Picture from Joshua Tree."
height="100" width="100" >
<button
type=button
onclick="show_image('WebVuCoolOldBulb-2.jpg', 276, 110, 'Light Bulb');">
Add Lightbulb
</button>
</form>
<script>
//https://stackoverflow.com/questions/25487865/html5-div-hidden-show-on-click
function show_image(src, width, height, alt) {
var img = document.createElement("img");
img.src = src;
img.width = width;
img.height = height;
img.alt = alt;
// This next line will just add it to the <body> tag
document.body.appendChild(img);
}
</script>
</body>
</html>