如何禁用点击DIV内的所有元素?
<div id=largerdiv>
<button id=haha>haha1</button>
<textarea > </textarea>
</div>
我想禁用点击上面div中的两个元素
答案 0 :(得分:0)
禁用所有输入..
$("#discobal :input").prop("disabled", true);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<form id="discobal">
<textarea>abc</textarea>
<button>abc</button>
</form>
使用div:
$("#discobal :input").prop("disabled", true);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="discobal">
<textarea>abc</textarea>
<button>abc</button>
</div>
使用clickker:
$("#repensteeltje").click(function() {
$("#discobal :input").prop("disabled", true);
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="discobal">
<textarea>abc</textarea>
<button>abc</button>
</div>
<button id="repensteeltje">Disable all</button>
答案 1 :(得分:-1)
只需在两个元素上设置disabled属性:
<textarea disabled></textarea>
<button disabled></button>
&#13;