how to change values of a dropdown on key press using jquery
i need to change values of a "Focused" dropdown on keypress using jquery.
i need,
- how i get a foucsed drop down or how i can check whether the drop down 开发者_JAVA百科has focus.
- how to change this drop down values in key press like 1,2,3 etc. using JQUERY.
thanks in advance.
To see if object is selected:
if($(".foo").is(':focus')){
// do something
}
To change values on keypress:
$(".foo").bind("keypress", function(e){
$(this).attr('value', 'bar');
})
Though not sure what you mean by changing the values of a drop down, or why you'd want to do that.
精彩评论