Hello, i need to add a classname to an element <ausing JavaScript.
I've tried a couple of thing with no success.
This is an small piece of my code:
....
<li><a href="<?php echo $cd_img; ?>" onClick="show_p icture(this);
return false;">image 1</a></li>
<li><a href="<?php echo $cd_img; ?>" onClick="show_p icture(this);
return false;">image 2</a></li>
....
<img id="cover" src="<?php echo $cd_cover; ?>" alt="" /></div>
function show_picture(pi cture) {
var source = picture.getAttr ibute("href");
var cover = document.getEle mentById("cover ");
cover.setAttrib ute("src", source);
//??????doesnt work
var el_a = document.getEle mentById("a");
el_a.className = "here";
}
Any ideas?
Thanks
Marco
I've tried a couple of thing with no success.
This is an small piece of my code:
....
<li><a href="<?php echo $cd_img; ?>" onClick="show_p icture(this);
return false;">image 1</a></li>
<li><a href="<?php echo $cd_img; ?>" onClick="show_p icture(this);
return false;">image 2</a></li>
....
<img id="cover" src="<?php echo $cd_cover; ?>" alt="" /></div>
function show_picture(pi cture) {
var source = picture.getAttr ibute("href");
var cover = document.getEle mentById("cover ");
cover.setAttrib ute("src", source);
//??????doesnt work
var el_a = document.getEle mentById("a");
el_a.className = "here";
}
Any ideas?
Thanks
Marco
Comment