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 class="back">
<input id="ID1" type="button" value="click" onclick="action1(this)">
</div> <div class="shade hide"></div>
<div class="models hide">
<input id="ID2" 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 id="outer">
<div class="item">
<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>

jQuery 练习:取出数组字典的值, 静态对话框, clone方法应用的更多相关文章

  1. JS去除数组中重复值的四种方法

    JS去除数组中重复值的四种方法 1 /// <summary>            o[this[i]] = "";  }      }       newArr.p ...

  2. PHP中多维数组查找某个值是否存在的方法

    in_array — 检查数组中是否存在某个值,只是这个方法不能检查多维数组. 所以可以编写类似下面的递归方法来检查多维数组. function deep_in_array($value, $arra ...

  3. IOS NS 字符串 数组 字典 文件 动态 静态 操作

    ios 常用字符串的操作   //将NSData转化为NSString        NSString* str = [[NSString alloc] initWithData:response e ...

  4. AJPFX关于数组获取最值的思路和方法

    思路分析:1.定义一个变量(max,初始值一般为数组中的第一个元素值),用来记录最大值.2.遍历数组,获取数组中的每一个元素,然后依次和max进行比较.如果当前遍历到的元素比max大,就把当前元素值给 ...

  5. 浏览器后退按钮导致jquery动态添加的select option值丢失的解决方法

    监控浏览器返回功能 判断浏览器返回功能 禁用浏览器的后退按钮 JS禁止浏览器后退键 http://volunteer521.iteye.com/blog/830522/ 浏览器返回功能 判断上一页面来 ...

  6. JQuery里属性赋值,取值prop()和attr()方法?

    1.赋值的时候 如果是<input type="checkbox" checked>这样的只有属性名就能生效的属性 推荐prop,即:$('input').prop(' ...

  7. python数组冒号取值操作

    1.冒号的用法 1.1 一个冒号 a[i:j] 这里的i指起始位置,默认为0:j是终止位置,默认为len(a),在取出数组中的值时就会从数组下标i(包括)一直取到下标j(不包括j) 在一个冒号的情况下 ...

  8. 取出关联数组的key值和values值

    取出关联数组的key值,可用 array_keys()取出; <?php $a=array("Volvo"=>"XC90","BMW&qu ...

  9. javascript 常见数组操作( 1、数组整体元素修改 2、 数组筛选 3、jquery 元素转数组 4、获取两个数组中相同部分或者不同部分 5、数组去重并倒序排序 6、数组排序 7、数组截取slice 8、数组插入、删除splice(需明确位置) 9、数组遍历 10、jQuery根据元素值删除数组元素的方)

    主要内容: 1.数组整体元素修改 2. 数组筛选 3.jquery 元素转数组 4.获取两个数组中相同部分或者不同部分 5.数组去重并倒序排序 6.数组排序 7.数组截取slice 8.数组插入.删除 ...

随机推荐

  1. Android Studio 常见问题及解决方法

    一.Error:All flavors must now belong to a named flavor dimension 问题描述: Error:All flavors must now bel ...

  2. 涨姿势:Spring Boot 2.x 启动全过程源码分析

    目录 SpringApplication 实例 run 方法运行过程 总结 上篇<Spring Boot 2.x 启动全过程源码分析(一)入口类剖析>我们分析了 Spring Boot 入 ...

  3. 机器学习(Machine Learning)算法总结-K临近算法

    一.算法详解 1.什么是K临近算法 Cover 和 Hart在1968年提出了最初的临近算法 属于分类(classification)算法 邻近算法,或者说K最近邻(kNN,k-NearestNeig ...

  4. [原创]K8 DB_Owner权限GetShell工具

    2011-04-23 02:19:56|  分类: 原创工具 DB_Owner权限拿Shell工具[K.8]Author: QQ吻Team:Crack8_TeamBlog:http://qqhack8 ...

  5. 基于vue-cli3.0构建功能完善的移动端架子,主要功能包括

    webpack 打包扩展 css:sass支持.normalize.css._mixin.scss._variables.scss vw.rem布局 跨域设置 eslint设置 cdn引入 路由设计. ...

  6. 一条sql解决.一张表的数据复制到另外一张表

    如何把一个表的数组复制到一张表?也许很多人会把这个表查出来的数据再插入到另外一张表里面,这样很麻烦又要写代码逻辑去处理,其实一条sql语句就可以把一张表的数据复制到另外一张表,或者一张表的某一条数据复 ...

  7. springBoot(3)---目录结构,文件上传

    目录结构,文件上传 一.目录结构 1.目录讲解 src/main/java:存放代码      src/main/resources                   static: 存放静态文件, ...

  8. App 性能相关

    51Testing系列丛书:性能测试学习笔记之 LoadRunner实战 http://www.51testing.com/html/38/n-3723938.html

  9. HP-JavaUtil: xls 操作类

    Written In The Font 谢谢,陈明.哈哈!共勉,努力搞定它. 路漫漫其修远兮,吾将上下而求索 Content ExportExcelAndSave( String[] header, ...

  10. MySQL导入导出实践

    最近一次数据迁移,需要将MySQL的数据导出.处理后导入到新表和ES.这里做个简单记录,方便后续查询. 注: 为了写文章方便及隐私安全,实际内容会有所简化.例如表结构简化.数据库连接部分全部用 xxx ...