Event on a disabled input

前端 未结 10 2463
攒了一身酷
攒了一身酷 2020-11-21 15:53

Apparently a disabled is not handled by any event

Is there a way to work around this issue ?



        
10条回答
  •  再見小時候
    2020-11-21 16:12

    Instead of disabled, you could consider using readonly. With some extra CSS you can style the input so it looks like an disabled field.

    There is actually another problem. The event change only triggers when the element looses focus, which is not logic considering an disabled field. Probably you are pushing data into this field from another call. To make this work you can use the event 'bind'.

    $('form').bind('change', 'input', function () {
        console.log('Do your thing.');
    });
    

提交回复
热议问题