jQuery 练习:取出数组字典的值, 静态对话框, clone方法应用
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了jQuery 练习:取出数组字典的值, 静态对话框, clone方法应用,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含3225字,纯文字阅读大概需要5分钟。
内容图文
jQuery 中文API文档 http://jquery.cuishifeng.cn/
jQuery 取出数组字典的值
<head>
<meta charset="UTF-8">
<title>Title</title>
<script src="jquery-3.3.1.min.js"></script>
</head>
<body>
<script>
li = [1, 2, 3, 4, 5]
$.each(li, function(i, x){
console.log(i, x) // i 为索引,x为 value
})
dic={name:"yuan", sex:"male"}
$.each(dic, function(i, x){
console.log(i,x) // i 为 key,x为value
})
</script>
</body>
jQuery 实现全选,取消,反选功能
<head>
<meta charset="UTF-8">
<title>Title</title>
<script src="jquery-3.3.1.min.js"></script>
</head>
<body>
<button onclick="selectall();">全选</button>
<button onclick="cancel();">取消</button>
<button onclick="reverse();">反选</button>
<table border="1">
<tr>
<td><input type="checkbox"></td>
<td>111</td>
</tr>
<tr>
<td><input type="checkbox"></td>
<td>222</td>
</tr>
<tr>
<td><input type="checkbox"></td>
<td>333</td>
</tr>
<tr>
<td><input type="checkbox"></td>
<td>444</td>
</tr>
</table>
<script>
function selectall(){
$("table :checkbox").each(function(){
$(this).prop("checked", true)
})
}
function cancel(){
$("table :checkbox").each(function(){
$(this).prop("checked", false)
})
}
function reverse(){
$("table :checkbox").each(function(){
if($(this).prop("checked")){
$(this).prop("checked", false);
}else {
$(this).prop("checked", true);
}
})
}
</script>
</body>
jQuery 实现静态对话框
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
.back{
background-color: rebeccapurple;
height: 2000px;
}
.shade{
position: fixed;
top: 0;
bottom: 0;
left: 0;
right: 0;
background-color: coral;
opacity: 0.4;
}
.hide{
display: none;
}
.models{
position: fixed;
top: 50%;
left: 50%;
margin-left: -100px;
margin-top: -100px;
height: 200px;
width: 200px;
background-color: gold;
}
</style>
<script src="jquery-3.3.1.min.js"></script>
</head>
<body>
<div >
<input type="button" value="click" onclick="action1(this)">
</div>
<div ></div>
<div >
<input type="button" value="cancel" onclick="action2(this)">
</div>
<script>
function action1(self){
$(self).parent().siblings().removeClass("hide");
}
function action2(self){
$(self).parent().parent().children(".shade, .models").addClass("hide");
}
</script>
</body>
jQuery clone方法应用
<head>
<meta charset="UTF-8">
<title>Title</title>
<script src="jquery-3.3.1.min.js"></script>
</head>
<body>
<div >
<div >
<input type="button" value="+" onclick="fun1(this)">
<input type="text">
</div>
</div>
<script>
function fun1(self){
var Clone=$(self).parent().clone();
Clone.children(":button").val("-").attr("onclick", "func2(this)");
$("#outer").append(Clone);
}
function func2(self){
$(self).parent().remove()
}
</script>
</body>
原文:https://www.cnblogs.com/klvchen/p/10400989.html
内容总结
以上是互联网集市为您收集整理的jQuery 练习:取出数组字典的值, 静态对话框, clone方法应用全部内容,希望文章能够帮你解决jQuery 练习:取出数组字典的值, 静态对话框, clone方法应用所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。