سؤال

 document.getElementById("buttonName").disabled=true;

So I know you can disable a button using this code. But i use pictures as buttons and they have an onClick function which i want to be able to disable. Is there any way to do this?

Also, only javascript, not jquery (if possible).

هل كانت مفيدة؟

المحلول

You can set onclick to null for your image-button to disable its onclick event.

document.getElementById("buttonName").onclick = null;

if you need to set a function to onclick event again:

document.getElementById("buttonName").onclick = funcToRun;
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top