表单上所有元素的共同事件 [英] common event for all elements on form

查看:77
本文介绍了表单上所有元素的共同事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在表单中任何元素的值更改时触发一个公共事件.根据表单元素的值,我要实现代码.

I want to fire a common event whenever a value of any element in form changes. On the basis of values of form elements i want implement code.

我正在编写下面的代码,但是onchange事件对付要求无效.

i am writing below code but onchange event is not working on formid.

$("#formid").change(function () {
    //code 
}); 

or this

$("#formid").bind("change", function () {
    //code 
});

如何在元素值发生任何变化时在表单上触发事件?

How to fire event on form whenever there is any change in element's value ?

推荐答案

如何在元素值发生任何变化时在表单上触发事件?

How to fire event on form whenever there is any change in element's value ?

只需按照看起来已完成的方式进行即可.将change事件绑定到form元素.

Just do as it looks like you've done. Bind the change event to the form element.

$("form").change(function() {
   // Some descendant changed.
});

只要您不干扰事件的传播,就可以使用.

So long as you're not interfering with the propagation of the events, this will work.

这篇关于表单上所有元素的共同事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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