jQuery removeAttr('type') doesn't work

前端 未结 3 1718
鱼传尺愫
鱼传尺愫 2021-01-18 01:00

My problem is very simple

$(\'#button\').removeAttr(\'type\');

triggers an error on firebug

type property can\'t be changed         


        
3条回答
  •  情话喂你
    2021-01-18 01:33

    Since you just want to disable the submit button:

    If you are using jQuery < 1.6 do this:

    $("#button").attr("disabled", 'disabled');
    

    If you are using jQuery 1.6+:

    $("#button").prop("disabled", true);
    

    See this question: .prop() vs .attr() for references why.

提交回复
热议问题