【发布时间】:2013-12-18 17:58:05
【问题描述】:
我有一段 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();
});
});
【问题讨论】:
-
什么不起作用?会不会是你没有
<ccit></ccit>元素? -
嗨,这是我编写的 html 代码,用于使该脚本执行操作
-
既然你已经发布了 HTML,它应该是
$("#ccit"),因此我的第一条评论 -
event.returnValue is deprecated. please use the standard event.preventDefault() instead只是对旧版本 jQuery 的警告,但这不是您的代码无法正常工作的原因。Javascript 是一种客户端语言,所以我不明白您的意思通过它不工作的服务器端。抱歉,我目前不知道如何为您提供帮助,除非您能准确地证明什么是行不通的。 -
@ThotaPallavi 试试我的
Update 2这是我能想到的最后一件事。
标签: javascript jquery html jsp