禁用禁用字段集中的某些元素

Thi*_*ijs 7 html disabled-input

fieldset禁用父级时,是否有办法(像元素上的属性一样)使特定元素“不可分散” ?最好没有任何JavaScript。如果不是,什么是禁用整个表格(有特定例外)的良好实践?

<fieldset disabled>
  Name: <input type="text"><br>

  <!-- Email shouldn't be disabled -->
  Email: <input type="text"><br>

  <!-- more fields ... -->
</fieldset>
Run Code Online (Sandbox Code Playgroud)

小智 0

亲爱的使用这个例子来实现你的目标。

 $(document).ready(function () {
            $('#form :input').prop('disabled', true);
            $("#btn1").prop('disabled', false);
        })
Run Code Online (Sandbox Code Playgroud)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<fieldset id="form">

  <legend>Personalia:</legend>
  Name: <input type="text" /><br />
  Email: <input type="text" /><br />
  Date of birth: <input type="text" />

  <input id="btn1" type="button" value="See More (Enable this!!) " onclick="ButtonClicked1()" />
  Somethingelse: <input type="text" />
 <input type="button" value="View Details " onclick="ButtonClicked2()"/> 

  </fieldset>
Run Code Online (Sandbox Code Playgroud)

  • 感谢您的回答,但我想在没有 JavaScript 的情况下完成它。 (2认同)