Here is a simple code fiddle: http://jsfiddle.net/k5wfH/11/ which is not working for me for 2 days straight.
In my website, the 2nd, i.e. the
flag
image style display change works, but the 1st, i.e. the
upvote
image style display change does not work. However in Fiddle, both of the style display change functions are not working.
HTML:
<img id='upgrey' class='up' src='http://s24.postimg.org/8v77coekx/up_grey.png' width='26px' onclick='upvote();'>
<img id='upgold' class='up' src='http://s24.postimg.org/jtdvh4dsh/up_raised.png' width='26px' style='display:none'>
<img id='flaggrey' class='flag' src='http://s1.postimg.org/egcymr8cb/flag_grey.png' height='26px' onclick='flag();'>
<img id='flagred' class='flag' src='http://s1.postimg.org/a5yar6397/flag_raised.png' height='26px' style='display:none'>
JS
function upvote() {
document.getElementById("upgrey").setAttribute("style", "display:none");
document.getElementById("upgold").setAttribute("style", "display:block");
}
function flag() {
document.getElementById("flaggrey").setAttribute("style", "display:none");
document.getElementById("flagred").setAttribute("style", "display:block");
}
I thought this was the bread and butter functionality of JavaScript and no idea what else I can do at all to fix this.
Ah, when the simple things fail to work!
Edit: Seems like another div's padded region was covering one of the images (almost completely ~95%) and i was unable to click the image and rather just clicking the other div's padded region. Everything is sorted out. Learned a thing or two here. Thank you everyone.