我想在只读的文本框的变化上具有一些功能。 但是当我试图更新使用JavaScript的文本框时,更改事件不会触发文本框。只读属性为TextBox消防onchange事件为真
<script type="text/javascript">
$(document).ready(function() {
$('input[id$=_txtTest]').bind("change", function() {
alert("test");
});
});
function ChangeText() {
$('input[id$=_txtTest]').val('hello');
}
</script>
我在点击按钮时调用ChangeText方法。但它不会触发文本框的textchange事件。
有人可以告诉我这里有什么问题吗?
可能的复制:http://stackoverflow.com/questions/3600680/input-textbox-onchange-is-not-firing-when-data-is-assigned-to-input-textbox?rq=1 –
同样重复于:http://stackoverflow.com/questions/4672505/why-does-the-jquery-change-event-not-trigger-when-i-set-the-value-of-a-select-us –
您在输入框中只读设置为true?当你打电话给ChangeText时,这个值是否真的变成'hello'? –