I have written a function which quite simply changes the style attributes of an image when clicked.
document.getElementById(normal + current).setAttribute('style', 'display: block;');
current is a parameter for the function. e.g. changeImage(10)
and the element image which we want to change the style for has a resultant id of normal10.
To make it display, basically as it's set as display: none obviously to begin with, we need to change that to block.
So, I have two instances where I call the method changeImage(current).
One which is:
<a href=# onclick=changeImage(10);><img src=xyz></img></a>
and another which is:
<a href=javascript: changeImage(10);><img src=xyz></img></a>
Both of these function correctly on Chrome & Opera, the display attribute is changed both times.
However on any other browser such as IE or Firefox, the display attribute only seems to get changed where we have
<a href=javascript...>
and not where the method is called upon via the onclick.
I tried to change to:
document.getElementById(normal + current).style.display=block;
Unfortunately to no avail.
I don't think there is an issue with the javascript itself. Since the function executes fine when called within the href.
Does anybody have any ideas?
Thanks!
EDIT:
Done with jQuery, code executes but the style of the image still doesn't change. Works in Chrome & Opera still but not in firefox & IE.
I gave the image that is clicked to execute the function an id of img.
<img id=img src=...></img>
and the code to execute the function is placed in the following tags (in document ready function):
$('#img').click(function(){}
Code is executed, but style is only changed from none to block on specific browsers.