I have an icon on a page, what when clicked is calling a function from an external JS file.
<input type="checkbox" checked="checked" id="myCheck"/>
<img src="icon.png" id="myIcon" onclick="myFunction)(this,null,null)" />
I need to add a functionality to disable this click when a checkbox is checked, and allow click and calling the JS function if the checkbox is not selected.
Tried this but it does not seem to work. What am I missing?
$("#myCheck").prop("checked", true).click(function(event){
event.stopPropagation();
});
UPDATE: since I do not have much control over code that is not in the header in this particular case, and can not remove onclick="myFunction)(this,null,null) from img tag, is there still a way to disable click action if the checkbox is selected. Perhaps I can remove HTML. What would JS be considered here? It's not an attribute...