Why can't I change the type of an input element to submit?

前端 未结 7 1302
盖世英雄少女心
盖世英雄少女心 2021-01-01 11:52

I\'m calling this function:

function submit_button(button_id){
    $(\'#\' + button_id).attr(\'type\', \'submit\');
}

to make this button t

7条回答
  •  生来不讨喜
    2021-01-01 12:15

    javascript:

    function submit_button(){
    
          var btn=document.getElementById('button_id');
          btn.setAttribute('type', 'submit');
    
      }
    

    ======================================================================

    Jquery:

    function submit_button(){
    
     $('#' + button_id).prop('type', 'submit');
    
       }
    

    ======================================================================

提交回复
热议问题