如何禁用jQuery中的字段集中的所有元素? [英] How can I disable all elements inside a fieldset in jQuery?

查看:102
本文介绍了如何禁用jQuery中的字段集中的所有元素?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的页面上有2个<fieldset>,但是其中之一应根据某些用户的选择禁用所有元素.

I have 2 <fieldset>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 inputs, selects, and links. Is there a way to disable all of them instead of disabling them one by one?

推荐答案

如何使用子代选择器?

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

您还可以过滤孩子的选择:

You can also filter the children selection:

$("#myfieldeset").children("a,input");

这篇关于如何禁用jQuery中的字段集中的所有元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆