I'd like to change the "id" of an image (instead of toggleclass, because the class is already being used) like this :
<img src="<?php echo HTTP_IMAGES_PATH; ?>roof.png" class="img-responsive" id="roof" />
<button onclick="changeID('roof_red')">RED</button>
with the javascript part :
function changeID(this_color) {
$('roof').attr('id', this_color);
console.log(this_color);
}
And the HTML :
<button onclick="changeID('roof_red')">RED</button>
It is not working and when I look at the log, there's a reference error : $ is not defined... What am I doing wrong please?