Property 'checked' does not exist on type 'HTMLElement'.

后端 未结 1 1648
星月不相逢
星月不相逢 2021-02-19 13:14

I have this code in typescript file

 function debug_show_removed_flights() {
    if ($(\'.debug-window #show_removed_flights\')[0].checked) {
      $(\'.fly-sche         


        
1条回答
  •  生来不讨喜
    2021-02-19 13:46

    Only HTMLInputElement have the checked property. You can cast your element so it will transpile:

    function debug_show_removed_flights() {
        const input = $('.debug-window #show_removed_flights')[0] as HTMLInputElement;
        if (input.checked) {
            $('.fly-schedule-removed_reason').show();
            return $('.fly-schedule-remove').show();
        } else {
            $('.fly-schedule-removed_reason').hide();
            return $('.fly-schedule-remove').hide();
        }
    }
    

    0 讨论(0)
提交回复
热议问题