开发者

how to change values of a dropdown on key press using jquery

开发者 https://www.devze.com 2023-02-13 16:16 出处:网络
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.

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

精彩评论

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

关注公众号