JavaScript noob here. I'm working on a website and I'm trying to change the z-index of a set of frames using buttons. I can't quite get it to work.
So far this is what I have.
function changeZIndex(i,id) {
document.getElementById(id).style.zIndex=i;
}
And in the body
<A HREF="#" onclick='changeZIndex(1,'aboutus')'><IMG NAME="one" SRC="button1.bmp"></A>
<A HREF="#" onclick='changeZIndex(1,'contactus')'><IMG NAME="two" SRC="button2.bmp"></A>
Yeah, I realize this is probably the stupidest question ever and the answer is really obvious. This is my first time writing JavaScript though, so please go easy on me! :3
Make sure your quotes are escaped correctly. try:
<a href="#" onclick="changeZIndex(1,'aboutus')"><img name="one" src="button1.bmp"></a>
<a href="#" onclick="changeZIndex(1,'contactus')"><img name="two" src="button2.bmp"></a>
note the double quotes around the onclick
Your quotation marks are wrong - look at the syntax highlighting:
<A HREF="#" onclick='changeZIndex(1,'aboutus')'><IMG NAME="one" SRC="button1.bmp"></A>
<A HREF="#" onclick='changeZIndex(1,'contactus')'><IMG NAME="two" SRC="button2.bmp"></A>
This is how you could do it:
<A HREF="#" onclick="changeZIndex(1,'aboutus')"><IMG NAME="one" SRC="button1.bmp"></A>
<A HREF="#" onclick="changeZIndex(1,'contactus')"><IMG NAME="two" SRC="button2.bmp"></A>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With