jquery问题求解决 jquery导航 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 $(document).ready(function(){ $('.error').hide(); $('.submit').click(function(event){ var count=$('input:checked').length; var amt=0; if(count==0){ $('p .result').hide(); $('.error').show(); }else{ $('form').find(':checkbox').each(funtion(){ if($(this).is(':checked')){ amt=amt+parseInt($(this).val()); } }); $('.error').hide(); $('p .result').show(); $('p .result').text('you bill is $'+amt); } event.preventDefault(); });});<html><head> <title>检查复选框是否被选中</title> <link rel="stylesheet" type="text/css" href="demo3.css" /> <script type="text/javascript" src="../jQuery1.8.3.js"></script> <script type="text/javascript" src="demo3.js"></script></head><body> <form> <input type="checkbox" name="pizza" value=5 class="infobox" />pizza $5<br /> <input type="checkbox" name="hotdog" value=2 class="infobox" />hotdog $2<br /> <input type="checkbox" name="coke" value=3 class="infobox" />coke $3<br /> <input type="checkbox" name="fries" value=6 class="infobox" />french fries $6<br /> <p class="error">至少选择一个复选框</p> <p class="result"></p> <input type="submit" class="submit" value="submit" /> </form></body></html>.infobox{margin-top:15px;}.submit{width:100px; height:30px; margin-left:150px; margin-top:10px;}.error{color:red;} $(document).ready(function(){ $('.error').hide();$('.result').hide(); $('.submit').click(function(event){ var count=$('input:checked').length; var amt=0; if(count==0){ $('p .result').hide(); $('.error').show(); }else{ $('form').find(':checkbox').each(function(){ if($(this).is(':checked')){ amt=amt+parseInt($(this).val()); } }); $('.error').hide(); $('.result').show(); $('.result').html('you bill is $'+amt); } event.preventDefault();return false; });}); return false 一下即可 就像楼上那样 php在服务器上创建文件权限的问题 php多个问题 这段代码怎么加首页和尾页 PHP+AJAX输出table时凭空多了一空行? 大家帮忙看看简历 给点意见 方向php 地点 广州 请教PHP换行符问题... 本人在湛江,现有一中小项目需外包,详情请电13536383607 为什么我的选择语句运行不了?? if {} else {} ??真的很奇怪!! 有空帮我看看 php编程中的.inc文件怎么获得,我的php中没有这些.inc文件,要下载吗? 关于在网页中如何将导航菜单打开的两个图片进行叠加 php无法打开pdo_odbc问题 怎么使用php制作一个课程(课程任选)教学资源网站
$('.error').hide();
$('.submit').click(function(event){
var count=$('input:checked').length;
var amt=0;
if(count==0){
$('p .result').hide();
$('.error').show();
}else{
$('form').find(':checkbox').each(funtion(){
if($(this).is(':checked')){
amt=amt+parseInt($(this).val());
}
});
$('.error').hide();
$('p .result').show();
$('p .result').text('you bill is $'+amt);
}
event.preventDefault();
});
});
<html>
<head>
<title>检查复选框是否被选中</title>
<link rel="stylesheet" type="text/css" href="demo3.css" />
<script type="text/javascript" src="../jQuery1.8.3.js"></script>
<script type="text/javascript" src="demo3.js"></script>
</head>
<body>
<form>
<input type="checkbox" name="pizza" value=5 class="infobox" />pizza $5<br />
<input type="checkbox" name="hotdog" value=2 class="infobox" />hotdog $2<br />
<input type="checkbox" name="coke" value=3 class="infobox" />coke $3<br />
<input type="checkbox" name="fries" value=6 class="infobox" />french fries $6<br />
<p class="error">至少选择一个复选框</p>
<p class="result"></p>
<input type="submit" class="submit" value="submit" />
</form>
</body>
</html>.infobox{margin-top:15px;}
.submit{width:100px; height:30px; margin-left:150px; margin-top:10px;}
.error{color:red;}
$('.error').hide();
$('.result').hide(); $('.submit').click(function(event){
var count=$('input:checked').length;
var amt=0;
if(count==0){
$('p .result').hide();
$('.error').show();
}else{
$('form').find(':checkbox').each(function(){
if($(this).is(':checked')){
amt=amt+parseInt($(this).val());
}
});
$('.error').hide();
$('.result').show();
$('.result').html('you bill is $'+amt);
}
event.preventDefault();
return false;
});
});