JQuery - Set Attribute value

前端 未结 6 573
旧时难觅i
旧时难觅i 2021-02-05 02:22

I have following HTML with two elements having the same name




        
6条回答
  •  一个人的身影
    2021-02-05 02:51

    "True" and "False" do not work, to disable, set to value disabled.

    $('.someElement').attr('disabled', 'disabled');

    To enable, remove.

    $('.someElement').removeAttr('disabled');

    Also, don't worry about multiple items being selected, jQuery will operate on all of them that match. If you need just one you can use many things :first, :last, nth, etc.

    You are using name and not id as other mention -- remember, if you use id valid xhtml requires the ids be unique.

提交回复
热议问题