JQuery - Set Attribute value

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

I have following HTML with two elements having the same name




        
6条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-02-05 02:49

    Use an ID to uniquely identify the checkbox. Your current example is trying to select the checkbox with an id of '#chk0':

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

    You'll also need to remove the attribute for disabled to enable the checkbox. Something like:

    $('#chk0').removeAttr("disabled");

    See the docs for removeAttr

    The value XHTML for disabling/enabling an input element is as follows:

    
    
    

    Note that it's the absence of the disabled attribute that makes the input element enabled.

提交回复
热议问题