jQuery的题
来源:互联网 发布:js equals方法 编辑:程序博客网 时间:2024/06/03 21:47
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script src="jQuery-2.1.0/jquery-2.1.0.js"></script>
</head>
<body>
<center>
<h3> 用户注册</h3>
<table border="1px solid" cellpadding="10px" cellspacing="0px">
<tr>
<td>用户名</td>
<td><input type="text" placeholder="用户名不能为空"/></td>
</tr>
<tr>
<td>密码</td>
<td><input type="password" placeholder="长度在4-16位之间"/></td>
</tr>
<tr>
<td>年龄</td>
<td><input type="text" placeholder="年龄必须是数字" /></td>
</tr>
<tr>
<td>性别</td>
<td><input type="radio" name="l" />男<input type="radio" name="l" />女</td>
</tr>
<tr>
<td>住址</td>
<td id="zhuzhitd">
省<select id="sheng">
<option id="b">北京</option>
<option id="h">黑龙江</option>
<option id="s">上海</option>
</select>
市<select id="shi">
<option selected='selected'>中南海</option> <option>奥运村</option> <option>二环</option>
</select>
</td>
</tr>
<tr>
<td colspan="2" align="center"><button id="submit">提交</button></td>
</tr>
</table>
<button id="delete">批量删除</button>
<table id="table2" border="1px solid" cellpadding="10px" cellspacing="0px" >
<tr><td><input type="checkbox" id="check1"></td><td>用户名</td><td>密码</td><td>年龄</td><td>性别</td><td>住址</td></tr>
</table>
</center>
<script type="text/javascript">
$("#sheng").change(function(){
var shengd=$(this).val();
if(shengd == "北京"){
var beijing=$("<option selected='selected'>中南海</option> <option>奥运村</option> <option>二环</option>");
$("#shi").html(beijing);
}
if(shengd == "上海"){
var shanghai=$("<option>北戴河</option><option>长三角</option><option>门头沟</option>");
$("#shi").html(shanghai);
}
if(shengd == "黑龙江"){
var heilongjiang=$("<option>齐齐哈尔</option><option>牡丹江</option><option>哈尔滨</option>");
$("#shi").html(heilongjiang);
}
});
$("#submit").click(function(){
var name=$("input:eq(0)").val();
var mm=$("input:eq(1)").val();
var nl=$("input:eq(2)").val();
var aaa=false;
var bbb=false;
var ccc=false;
var ddd=false;
if(name==""||name==null){
aaa=false;
alert("用户名为空");
}else{ aaa=true;}
if(mm.length>4&&mm.length<16){
bbb=true;
}else{bbb=false; alert("密码位数不对");}
if(nl==""||nl==null){
ccc=false;
}else{
if(!isNaN(nl)){
ccc=true;
}else{
ccc=false;
alert("年龄必须为数字");
}
}
var flag1=$('input:radio:eq(0):checked').val();
var flag2=$('input:radio:eq(1):checked').val();
var sex;
if(flag1==null&&flag2==null){
ddd=false;
alert("性别必填");
}else{
if(flag1!=null){
sex="男";
}
if(flag2!=null){
sex="女";
}
ddd=true;
}
if(aaa&&bbb&&ccc&&ddd){
var sheng=$("#sheng").val()
var shi=$("#shi").val();
var table2=$("#table2");
var add=("<tr><td><input type='checkbox' class='check'></td><td>"+name+"</td><td>"+mm+"</td><td>"+nl+"</td><td>"+sex+"</td><td>"+sheng+"-"+shi+"</td></tr>");
$("#table2").append(add);
}else{
alert("填写项不满足要求");
}
});
var a=0;
$("#check1").click(function(){
if(a==0){
$(".check").prop("checked","true");
a=1;
}else{
$(".check").prop("checked",false);
a=0;
}
});
$("#delete").click(function(){
$("#table2 :checked").not("[id]").parent().parent().remove();
});
</script>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script src="jQuery-2.1.0/jquery-2.1.0.js"></script>
</head>
<body>
<center>
<h3> 用户注册</h3>
<table border="1px solid" cellpadding="10px" cellspacing="0px">
<tr>
<td>用户名</td>
<td><input type="text" placeholder="用户名不能为空"/></td>
</tr>
<tr>
<td>密码</td>
<td><input type="password" placeholder="长度在4-16位之间"/></td>
</tr>
<tr>
<td>年龄</td>
<td><input type="text" placeholder="年龄必须是数字" /></td>
</tr>
<tr>
<td>性别</td>
<td><input type="radio" name="l" />男<input type="radio" name="l" />女</td>
</tr>
<tr>
<td>住址</td>
<td id="zhuzhitd">
省<select id="sheng">
<option id="b">北京</option>
<option id="h">黑龙江</option>
<option id="s">上海</option>
</select>
市<select id="shi">
<option selected='selected'>中南海</option> <option>奥运村</option> <option>二环</option>
</select>
</td>
</tr>
<tr>
<td colspan="2" align="center"><button id="submit">提交</button></td>
</tr>
</table>
<button id="delete">批量删除</button>
<table id="table2" border="1px solid" cellpadding="10px" cellspacing="0px" >
<tr><td><input type="checkbox" id="check1"></td><td>用户名</td><td>密码</td><td>年龄</td><td>性别</td><td>住址</td></tr>
</table>
</center>
<script type="text/javascript">
$("#sheng").change(function(){
var shengd=$(this).val();
if(shengd == "北京"){
var beijing=$("<option selected='selected'>中南海</option> <option>奥运村</option> <option>二环</option>");
$("#shi").html(beijing);
}
if(shengd == "上海"){
var shanghai=$("<option>北戴河</option><option>长三角</option><option>门头沟</option>");
$("#shi").html(shanghai);
}
if(shengd == "黑龙江"){
var heilongjiang=$("<option>齐齐哈尔</option><option>牡丹江</option><option>哈尔滨</option>");
$("#shi").html(heilongjiang);
}
});
$("#submit").click(function(){
var name=$("input:eq(0)").val();
var mm=$("input:eq(1)").val();
var nl=$("input:eq(2)").val();
var aaa=false;
var bbb=false;
var ccc=false;
var ddd=false;
if(name==""||name==null){
aaa=false;
alert("用户名为空");
}else{ aaa=true;}
if(mm.length>4&&mm.length<16){
bbb=true;
}else{bbb=false; alert("密码位数不对");}
if(nl==""||nl==null){
ccc=false;
}else{
if(!isNaN(nl)){
ccc=true;
}else{
ccc=false;
alert("年龄必须为数字");
}
}
var flag1=$('input:radio:eq(0):checked').val();
var flag2=$('input:radio:eq(1):checked').val();
var sex;
if(flag1==null&&flag2==null){
ddd=false;
alert("性别必填");
}else{
if(flag1!=null){
sex="男";
}
if(flag2!=null){
sex="女";
}
ddd=true;
}
if(aaa&&bbb&&ccc&&ddd){
var sheng=$("#sheng").val()
var shi=$("#shi").val();
var table2=$("#table2");
var add=("<tr><td><input type='checkbox' class='check'></td><td>"+name+"</td><td>"+mm+"</td><td>"+nl+"</td><td>"+sex+"</td><td>"+sheng+"-"+shi+"</td></tr>");
$("#table2").append(add);
}else{
alert("填写项不满足要求");
}
});
var a=0;
$("#check1").click(function(){
if(a==0){
$(".check").prop("checked","true");
a=1;
}else{
$(".check").prop("checked",false);
a=0;
}
});
$("#delete").click(function(){
$("#table2 :checked").not("[id]").parent().parent().remove();
});
</script>
</body>
</html>
阅读全文
0 0
- jQuery的题
- jQuery的“$”
- jQuery-强大的jQuery选择器
- 认识jQuery-《锋利的jQuery》
- jQuery-强大的jQuery选择器
- jQuery-强大的jQuery选择器
- 【jquery】jquery插件的开发
- jQuery-强大的jQuery选择器
- jQuery 3.0:新一代的 jQuery
- jQuery-强大的jQuery选择器
- JQuery-Jquery的TreeGrid插件
- 锋利的jQuery(jQuery选择器)
- 【jquery】jquery的各种方法的积累
- 《锋利的jQuery》二、jQuery的选择器
- 《锋利的jQuery》四、jQuery的事件
- 《锋利的jQuery》五、jQuery的动画
- 《锋利的jQuery》十二、jQuery的技巧
- jquery的jQuery pager plugin(jquery.pager.js)简单应用
- 2.UE4的变量
- xrecyclerview 实现下拉刷新下拉加载
- centos安装最新版docker
- 事件分发
- Nonlinear Image Enhancement to Improve Face Detection in Complex Lighting Environment 翻译
- jQuery的题
- Java.Utils得到并验证4位数的验证码(没看懂,有待研究)
- mysql备份--心得
- GreenDao的简单存储
- 这是我的第一个程序
- Go语言web简单配置
- HTML总结
- Magic Powder
- javase基础总结(周总结)