I have the following script provided by user Vincent - he really helped me out but I just haven't got the understanding to finish it on my own...
It adds a '_' prefix to an image file onclick (swapping '1.gif', say, for '_1.gif').
To complete I need some way of swapping back onclick (removing that '_' prefix if it is present).
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
var prefix = "_";
function showNextPic(imgelement)
{
var src = imgelement.attr('src');
if(src.indexOf(prefix) == -1) {
src = prefix + src;
}
imgelement.attr('src', src);
}
</script>
with
onClick="showNextPic($(this))
with each image.
Can anyone help me remove that prefix if it's present?
Thanks very much for reading!