How can I disable all elements inside a fieldset in jQuery?

后端 未结 6 1884
夕颜
夕颜 2021-02-07 06:22

I have 2

s on my page, but one of them should have all of it elements disabled depending on some user\'s choice.

The fieldsets contain text

6条回答
  •  梦毁少年i
    2021-02-07 06:47

    In addition to what others posted:

    Use .prop() instead of .attr():

    $('#myfieldset').prop('disabled',true)
    

    It is more correct with regard to the DOM.

    And it does not seem to work well with validation. Both firefox and chrome won't let me submit the form With unfilled 'required' inputs in the disabled fieldset, but don't give any instructions on how to complete the form either.

提交回复
热议问题