I have this code:
https://jsfiddle.net/Suiberu/rxu8wgxf/
//INPUT RADIO ON & OFF
var prv;
var markIt = function(e) {
if (prv === this && this.checked) {
this.checked = false;
prv = null;
} else {
prv = this;
}
};
$(function() {
$('input.limit_radio').on('click', markIt);
});
//CHANGE IMAGE
function changeImage(imgName) {
image = document.getElementById('theimage');
image.src = imgName;
}
I removed the onclick handler and added a data attribute to swap out the urls.
https://jsfiddle.net/jjwilly16/37yn9xzy/1/.
<img src="http://www.cbc.ca/i/img/theme/default/plus-up.png" name="theimage" id="theimage" data-alternate="https://www.ucl.ac.uk/2034/images/icons/arrow-blue-left.png"/>
/INPUT RADIO ON & OFF
var prv;
var markIt = function(e) {
if (prv === this && this.checked) {
this.checked = false;
prv = null;
} else {
prv = this;
}
var img = document.getElementById('theimage'),
alternate = img.getAttribute('data-alternate'),
src = img.src;
img.src = alternate;
img.setAttribute('data-alternate', src);
};
$(function() {
$('input.limit_radio').on('click', markIt);
});