I am trying to fetch the changed input filed value using jquery which is getting changed javascript event of drop down select. I simply am not getting where exactly the things are getting wrong. It is something related to dom tree refresh (.live)? Any help/suggestions would be great. Thanks.
/* adding the value to user_val input field id in javascript onload function based on drop down select event*/
document.getElementById('user_val').Value = "abcd";
/* then trying to get value which changed */
$(document).ready(function() {
$("#sub开发者_JAVA技巧mits").click(function() {
alert($("#user_val").val());
});
You haven't closed your click
event handler function. Change it to this:
$(document).ready(function() {
$("#submits").click(function() {
alert($("#user_val").val());
});
});
And change Value
to value
(note the lowercase "v"), and then it should work fine.
Two errors you got there:
You should use
document.getElementById('user_val').value = "abcd";
and notdocument.getElementById('user_val').Value = "abcd";
(lower casevalue
, notValue
).You should also close the ready event after your click event.
Here is the complete working solution:
/* adding the value to user_val input field id in javascript onload function based on drop down select event*/ document.getElementById('user_val').value = "abcd"; /* then trying to get value which changed */ $(document).ready(function() { $("#submits").click(function() { alert($("#user_val").val()); }); });
精彩评论