简体   繁体   English

什么是正确的焦点和 focuseout javascript 下拉功能?

[英]what are the right focus and focuseout javascript functions for dropdowns?

The following function works fine for the text inputs.以下 function 适用于文本输入。 How do I create a similar effect for drop downs (select)?如何为下拉菜单(选择)创建类似的效果?

$('input').focus(function(){
    $(this).css('opacity',1);
});
$('input').focusout(function(){
    $(this).css('opacity',0.6);
});

Simply add 'select' in your jQuery selector:只需在 jQuery 选择器中添加“选择”:

$('input, select')

Note that because of the way focus works on select elements, the effect won't occur until the user clicks off of the select a second time (if they haven't changed the selected option).请注意,由于焦点在 select 元素上的工作方式,直到用户再次单击 select (如果他们没有更改所选选项),效果才会发生。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM