Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
44
rated 0 times [  51] [ 7]  / answers: 1 / hits: 31174  / 12 Years ago, tue, january 15, 2013, 12:00:00

I am trying to have some functionality on change of a textbox which is readonly.
But when I am trying to update the textbox using javascript, the change event is not firing for the textbox.



<script type=text/javascript>
$(document).ready(function () {
$('input[id$=_txtTest]').bind(change, function () {
alert(test);
});
});
function ChangeText() {
$('input[id$=_txtTest]').val('hello');
}
</script>


I am calling ChangeText method on click of a button. But it is not firing the textchange event for the textbox.



Can anybody tell me what is wrong here?


More From » jquery

 Answers
6

Well you have to do this way: http://jsfiddle.net/kmvSV/1/



 $(document).ready(function () {
$('input[id$=_txtTest]').bind(change, function () {
alert($(this).val());
});
$('button').bind(click, function () {
$('input[id$=_txtTest]').val('hello').trigger('change');
});
});

[#80872] Sunday, January 13, 2013, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
shylaelisan

Total Points: 37
Total Questions: 94
Total Answers: 110

Location: Angola
Member since Tue, May 5, 2020
4 Years ago
;