从使用jQuery .change选择框失去焦点()事件 [英] Lose Focus from Select Box with Jquery .change() event

查看:996
本文介绍了从使用jQuery .change选择框失去焦点()事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用你从下拉的东西之后,会显示几个表单字段下拉。我已绑定的下拉使用jQuery来检测一个变化,但是,盒必须'失去焦点'触发.change之前。任何方式来解决这个问题?

  $(#EmployeeSelected)。改变(函数(){
        警报('你好');
    });


解决方案

这似乎并不需要失去焦点,至少与传统的变更。如果使用的是不断变化的,即按键的另一种形式,你可能需要考虑额外的结合事件吧。

这应该火,你拥有它,只要你是传统意义上的选择它的(点击选项)的。如果您使用的是不同的方法,的如键盘输入的,你需要绑定正确的事件吧,如键preSS 的keydown

工作演示

I am using a dropdown which displays several form fields after you choose something from the dropdown. I have bound the dropdown with jquery to detect a change, however, the box must 'lose focus' before the .change is triggered. Any way to fix this?

    $("#EmployeeSelected").change(function () {
        alert('hi');
    });

解决方案

It doesn't appear to require losing focus, at least with an traditional change. If you are using another form of changing, ie keystrokes, you may want to consider binding additional events to it.

It should fire as you have it, as long as you are selecting it in the traditional sense (Clicking the option). If you are using a different method, such as keyboard input, you will need to bind the proper events to it, such as keypress, keydown, etc.

Working Demo

这篇关于从使用jQuery .change选择框失去焦点()事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆