开发者

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,

  1. how i get a foucsed drop down or how i can check whether the drop down 开发者_JAVA百科has focus.
  2. 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.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜