107
rated 0 times
[
111]
[
4]
/ answers: 1 / hits: 24299
/ 11 Years ago, sat, may 18, 2013, 12:00:00
I thought doing something like this would have worked, but I'm confused as to why it isn't when the style is hiding the image to begin with, but not showing it when the button is pressed. Here's the code:
function showImg() {
x=document.getElementById(map_img)
x.style.visibility=visible;
}
<body>
<img id=map_img src=map.jpg style=visibility:hidden width=400 height=400/>
<form id=form1 name=form1 align=center>
<input type=submit id=Map value=Map onclick=showImg()/>
</form>
I've also tried this in both situations:
<input type=button id=Map value=Map onclick=showImg()/>
and:
<style>
.hidden{display:none;}
.show{display:block;}
</style>
function showImg() {
x=document.getElementById(map_img)
x.class=show;
}
<body>
<img id=map_img src=map.jpg class=hide width=400 height=400/>
<form id=form1 name=form1 align=center>
<input type=submit id=Map value=Map onclick=showImg()/>
</form>
I'm really lost as to how neither of these worked, could I get some help on this please?
More From » javascript