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

后端 未结 6 1882
夕颜
夕颜 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条回答
  •  日久生厌
    2021-02-07 07:01

    Why don't you just use:

    $("#myfieldeset").attr("disabled", "disabled");

    It worked for me. It disabled nicely all the children inputs.

    EDIT: note thas the disabled attribute can be applied to fieldset element only in HTML5 (see merryprankster comment). Strangely enough, it does work with other browser than just Firefox and Opera, such as Chrome and Internet Explorer (tested IE7 and IE8).

提交回复
热议问题