复选框绑定CHANGE事件 [英] Checkbox bind CHANGE event

查看:186
本文介绍了复选框绑定CHANGE事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在用户点击/触摸复选框后提交表单:



HTML



<$ p data =true/><< ; label for =chkSales>销售< / label>
< input type =checkboxname =chkArrivalid =chkArrivalclass =customdata-inline =truedata-mini =true/>< label for = chkArrival>新到达< / label>


Js:



< pre $ $(input [type ='checkbox'])。change(function(){
alert(e);
print(e);
});

从我在这里读到的应该真的有效,但是id doenst!我的问题在哪里?



(应该是更改,因为移动设备不点击,他们使用触摸...
http://jsfiddle.net/usTHG/2/

解决方案

  $(input [type ='checkbox'])。change(function(e){
^ e这里
alert(e.type);
print(e);
});

工作示例


I want to submit my form after a user clicked/touched the checkbox:

THE HTML

<input type="checkbox" name="chkSales" id="chkSales" class="custom" data-inline="true" data-mini="true"/><label for="chkSales">Sales</label>                                         
<input type="checkbox" name="chkArrival" id="chkArrival" class="custom" data-inline="true" data-mini="true"/><label for="chkArrival">New Arrival</label>                                                         

​ The Js:

$("input[type='checkbox']").change(function() {
    alert(e);
    print(e);
});​

From what I read here it should really work, but id doenst! where is my problem?

(it should be change, since mobile devices don't click, they use touch... http://jsfiddle.net/usTHG/2/

解决方案

$("input[type='checkbox']").change(function(e) {
                                            ^---- you missed e here
    alert(e.type); 
    print(e);
});​

Working example

这篇关于复选框绑定CHANGE事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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