jQuery mobile checkbox的事件触发为什么会有两次
1个回答
2016-05-07 · 百度知道合伙人官方认证企业
育知同创教育
1【专注:Python+人工智能|Java大数据|HTML5培训】 2【免费提供名师直播课堂、公开课及视频教程】 3【地址:北京市昌平区三旗百汇物美大卖场2层,微信公众号:yuzhitc】
向TA提问
关注
展开全部
加了个直接用最彻底的return false试了下
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="format-detection" content="telephone=no" />
<title>北京银行信用卡网络申请</title>
<link rel="stylesheet" href="css/jquery.mobile.flatui.css">
<script src="js/jquery.js"></script>
<script src="js/jquery.mobile-1.4.0-rc.1.js"></script>
<script>
$(document).ready(function () {
$("#nextbutton").on("tap", function () {
var val = $('input:checkbox[name="checkknow"]:checked').val();
if (val == null) {
$("#nextbutton").attr("href", "#");
$("p#warningtext").text("请阅读上述须知并点击同意");
} else {
$("#nextbutton").attr("href", "information.html");
$("p#warningtext").text("");
};
});
$("a#test1").on("tap", function () {
var val = $('input:checkbox[name="checkknow"]:checked').val();
alert(val);
$('input[type="checkbox"]').attr('checked', false).checkboxradio("refresh");
var val = $('input:checkbox[name="checkknow"]:checked').val();
alert(val);
$("#nextbutton").attr("data-theme", 'c').button("refresh");
});
/*
$("input[type='checkbox']").on("click", function () {
alert("Tap")
var val = $('input:checkbox[name="checkknow"]:checked').val();
if (val == null) {
alert("null");
//$("input[type='checkbox']").attr("checked",true).chec kboxradio("refresh");
//$("#nextbutton").button("disable");
}else{
alert("on");
}
//$("#nextbutton").button("diable").button("refresh");
});
*/
$("input[type='checkbox']").on("click", function () {
alert("click")
this.blur();
this.focus();
//$("#nextbutton").button("disable");
})
$("input[type='checkbox']").change(function(){
alert("Change");
var val = $('input:checkbox[name="checkknow"]:checked').val();
alert(val);
if(val == null){
$("#nextbutton").button("disable");
}
});
});
</script>
</head>
<body>
<div data-role="page" id="slide" data-theme="d">
<div data-role="header">
<h1>
申请卡片
</h1>
</div>
<div data-role="content">
<label for="checkknow">本人同意并遵守须知</label>
<input type="checkbox" name="checkknow" id="checkknow" data-theme="d" checked="true">
<button href="#" data-role="button" data-theme="d" id="nextbutton" data-ajax="false">下一步</button>
<a href="#" data-role="button" data-theme="d" id="test1" data-ajax="false">test</a>
<p id="warningtext"></p>
</div>
</div>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="format-detection" content="telephone=no" />
<title>北京银行信用卡网络申请</title>
<link rel="stylesheet" href="css/jquery.mobile.flatui.css">
<script src="js/jquery.js"></script>
<script src="js/jquery.mobile-1.4.0-rc.1.js"></script>
<script>
$(document).ready(function () {
$("#nextbutton").on("tap", function () {
var val = $('input:checkbox[name="checkknow"]:checked').val();
if (val == null) {
$("#nextbutton").attr("href", "#");
$("p#warningtext").text("请阅读上述须知并点击同意");
} else {
$("#nextbutton").attr("href", "information.html");
$("p#warningtext").text("");
};
});
$("a#test1").on("tap", function () {
var val = $('input:checkbox[name="checkknow"]:checked').val();
alert(val);
$('input[type="checkbox"]').attr('checked', false).checkboxradio("refresh");
var val = $('input:checkbox[name="checkknow"]:checked').val();
alert(val);
$("#nextbutton").attr("data-theme", 'c').button("refresh");
});
/*
$("input[type='checkbox']").on("click", function () {
alert("Tap")
var val = $('input:checkbox[name="checkknow"]:checked').val();
if (val == null) {
alert("null");
//$("input[type='checkbox']").attr("checked",true).chec kboxradio("refresh");
//$("#nextbutton").button("disable");
}else{
alert("on");
}
//$("#nextbutton").button("diable").button("refresh");
});
*/
$("input[type='checkbox']").on("click", function () {
alert("click")
this.blur();
this.focus();
//$("#nextbutton").button("disable");
})
$("input[type='checkbox']").change(function(){
alert("Change");
var val = $('input:checkbox[name="checkknow"]:checked').val();
alert(val);
if(val == null){
$("#nextbutton").button("disable");
}
});
});
</script>
</head>
<body>
<div data-role="page" id="slide" data-theme="d">
<div data-role="header">
<h1>
申请卡片
</h1>
</div>
<div data-role="content">
<label for="checkknow">本人同意并遵守须知</label>
<input type="checkbox" name="checkknow" id="checkknow" data-theme="d" checked="true">
<button href="#" data-role="button" data-theme="d" id="nextbutton" data-ajax="false">下一步</button>
<a href="#" data-role="button" data-theme="d" id="test1" data-ajax="false">test</a>
<p id="warningtext"></p>
</div>
</div>
</body>
</html>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询