我有一些HTML代码和脚本代码。我需要解决方案来处理一个文本框的更改事件,该文本框禁用在另一个文本字段中输入数据的行为。任何人都可以帮助我。
<div id="cca" class="leaf">
<label class="control input text" title="">
<span class="wrap">cca</span>
<input class="" type="text" value="[Null]"/>
<span class="warning"></span>
</label>
</div>
<div id="ccit" class="leaf">
<label class="control input text" title="">
<span class="wrap">ccit</span>
<input class="" type="text" value="[Null]"/>
<span class="warning"></span>
</label>
</div>
$(document).ready(function () {
alert("hello");
$("#cca").on('change', 'label.control input', function (event) {
alert('I am pretty sure the text box changed');
$("ccit").prop('disabled',true);
event.preventDefault();
});
});
答案 0 :(得分:10)
对于您#
$("ccit")
的人
$(document).ready(function () {
alert("hello");
$("#cca").change(function(){
alert('I am pretty sure the text box changed');
$("#ccit").prop('disabled',true);
event.preventDefault();
});
});
<强>更新强>
$(document).ready(function () {
$("#cca").on('change', 'label.control input', function (event) {
alert('I am pretty sure the text box changed');
$("#ccit").find('label.control input').prop('disabled',true);
event.preventDefault();
});
});
更新2
$(document).ready(function () {
$(document).on('change', '#cca label.control input', function (event) {
alert('I am pretty sure the text box changed');
$("#ccit").find('label.control input').prop('disabled',true);
event.preventDefault();
});
});
答案 1 :(得分:1)
$("#ccit").attr('disabled','disabled');
答案 2 :(得分:0)
您还可以在attr
$("ccit").attr('disabled',true);
如果prop
给您一个错误