<div class="rating" onclick="swapImg('good')"><img id="good" class="unselected" src="img/unrated.gif"/></div>
I am facing a strange issue with my JavaScript function. It seems that the entire img object is being passed into swapImg instead of just the string 'good'. When I use console.log(param) to log the parameter being passed into swapImg, this is what I see:
<img id="good" class="unselected" src="img/unrated.gif">
Can anyone help me figure out why this is happening?
function swapImg(imgId) {
console.log(imgId);
var image = document.getElementById(imgId);
console.log("success2");
}