Remove disabled attribute onClick of disabled form field

后端 未结 10 1458
眼角桃花
眼角桃花 2020-12-03 11:28

I have a form field that starts out disabled and has an onClick to enable it. The onClick doesn\'t fire (at least in FF) nor does a simple alert(1);.

The hacky vers

10条回答
  •  暖寄归人
    2020-12-03 12:17

    Don't implement the logic of the onClick event in the onClick's value of the input field. That's probably why it's not working in Firefox. Instead define a function as the onClick's value. For example:

    
    
    
    

    It will also be worth looking into JQuery. You can use it to add or remove attributes from elements and all kinds of other stuff. For instance you can remove the disabled from the the input field by writing a function like this:

    
    

    OR you can add it as follows:

    $("#date_end").attr('disabled','true');
    

    The Jquery site is here

提交回复
热议问题