Thursday 19 September 2013

multiple functions onclick addeventlistener

multiple functions onclick addeventlistener

I have the following code that works when triggered by an onclick for
example: onClick="change('imgA');"
function change(v) {
var target = document.getElementById("target");
if (v == "imgA") {target.className = "cast1";}
else if (v == "imgB") {target.className = "cast2";}
else if (v == "imgC") {target.className = "cast3";}
else if (v == "imgD") {target.className = "cast4";}
else {target.className = "chart";}
}
as soon as this result is stored to the id 'target', How do I perform this
same function again but with different classNames ('bio1' instead of
'cast1', etc). then save the results to a different id?
Everytime I've tried hasn't worked to this point.

No comments:

Post a Comment