简体   繁体   English

如果输入由div标记括起来,则禁用字段集的属性将不起作用

[英]Fieldset disabled property not working if input is enclosed by div tag

bootstrap's disabled property on fieldset is supposed to disable all inputs under that fieldset tag. 引导程序在fieldset上的disabled属性应该禁用该fieldset标签下的所有输入。 It works perfectly if input tags are right after fieldset tag or after legend tag. 如果输入标签紧接在字段集标签之后或图例标签之后,则它可以完美地工作。 As soon as I insert div tag between fieldset and input then disabled property is not working. 我在字段集和输入之间插入div标签后,disabled属性不起作用。

It works for following declaration... 它适用于以下声明...

<form id="form">
    <fieldset id="fieldset">
    <legend>User Details</legend>
            <input id="first_name" name="first_name" class="form-control" type="text"/>
    </fieldset>
</form>

But not If I add input inside div tag 但是如果我在div标签内添加输入

<form id="form">
    <fieldset id="fieldset">
    <legend>User Details</legend>
        <div class="col-xs-12 col-sm-6 col-md-4">
            <input id="first_name" name="first_name" class="form-control" type="text"/>
            </div>
    </fieldset>
</form>

Can anyone please suggest how to get around this problem? 有人可以建议如何解决这个问题吗?

First, disabled isn't a property of bootstrap; 首先, disabled不是引导程序的属性; it is native html. 它是本地html。

Second, it appears to work just fine. 其次,它似乎工作正常。 Are you perhaps using incompatible versions of jQuery/bootstrap? 您是否正在使用不兼容的jQuery / bootstrap版本?

<form id="form">
    <fieldset id="fieldset" disabled>
    <legend>User Details</legend>
        <div class="col-xs-12 col-sm-6 col-md-4">
            <input id="first_name" name="first_name" class="form-control" type="text"/>
            </div>
    </fieldset>
</form>

Working example: http://jsfiddle.net/remus/LAk6L/ 工作示例: http : //jsfiddle.net/remus/LAk6L/

尝试这个:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM