开发者

jQuery Change event for input and select elements

开发者 https://www.devze.com 2022-12-28 19:27 出处:网络
I am trying to alert something whenever a drop-down box changes and whenever something is typed into an input. I don\'开发者_运维百科t think I can use change for input fields? What would you use for i

I am trying to alert something whenever a drop-down box changes and whenever something is typed into an input. I don'开发者_运维百科t think I can use change for input fields? What would you use for input fields? Also, what about input fields of type file? Same thing. Here is what I have so far and it's not working:

$('input#wrapper, select#wrapper').change(function(){   
    alert('You changed.');
});


You can bind a keypress event to the text box.

$("#wrappertext").bind("keypress", function(){
   // your code
});

In your sample you have used the same id for the text box and the select box. Change this also.


when ever something is typed into an input

change() happens in input type text happens when the value is change on blur...

try keyup() or keydown() instead.

0

精彩评论

暂无评论...
验证码 换一张
取 消