日期:2014-05-17  浏览次数:20726 次

else 部分哪里不对,为什么不能跳转到/page/address页面?
$('.txt_pro img').click(function(){
if($(':input[type=checkbox]:checked').length == 0)
{
alert('must choose one product');return;
}
else
{
window.location.href="/page/address";
}
})

else 部分哪里不对,为什么不能跳转到/page/address页面?

------解决方案--------------------
if($(':input[type=checkbox]:checked').length == 0)
你这一句向判断什么啊

判断页面有选中的复选框?还是什么的?
------解决方案--------------------
探讨
if($(':input[type=checkbox]:checked').length == 0)
你这一句向判断什么啊

判断页面有选中的复选框?还是什么的?

------解决方案--------------------
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script src="Scripts/jquery-1.4.1.js" type="text/javascript"></script>
<script type="text/javascript">
function ChangeDateFormat(jsondate) {
jsondate = jsondate.replace("/Date(", "").replace(")/", "");
if (jsondate.indexOf("+") > 0) {
jsondate = jsondate.substring(0, jsondate.indexOf("+"));
}
else if (jsondate.indexOf("-") > 0) {
jsondate = jsondate.substring(0, jsondate.indexOf("-"));
}

var date = new Date(parseInt(jsondate, 10));
var month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
var currentDate = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
return date.getFullYear() + "-" + month + "-" + currentDate;
}
$(document).ready(function () {
$('.txt_pro img').click(function () {
if ($(':input[type=checkbox]:checked').length == 0) {
alert('must choose one product'); return;
}
else {
window.location.href = "/page/address";
}
});
});

</script>
</head>
<body>
<form id="form1" runat="server">
<div class="txt_pro img">
<img src="images/Demo.png" />
</div>
<input type="checkbox" id="cb1" name="cb1" value="1">1</inpu><br />
<input type="checkbox" id="cb2" name="cb2" value="2">2</inpu><br />
<input type="checkbox" id="cb3" name="cb3" value="3">3</inpu><br />
<input type="checkbox" id="cb4" name="cb4" value="4">4</inpu>
</form>
</body>
</html>
这个是我测试的代码
可以正常运行
------解决方案--------------------
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script src="Scripts/jquery-1.4.1.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function () {
$('.txt_pro img').click(function () {
if ($(':input[type=checkbox]:checked').length == 0) {
alert('must choose one product'); return;
}
else {
window.location.href = "/page/address";