js对象与jquery对象的相互转化:

1、$(js对象)

2、$(selector).get(索引)、$(selector)[索引]

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
div {
width: 700px;
height: 600px;
margin: 50px auto;
background-color: blue;
}
</style>
<script src="jquery-1.11.1.js"></script>
<script>
// $(document).ready(function () {
// $("button:eq(0)").click(function () {
// $("body").css("backgroundColor", "");
// });
// $("button:eq(1)").click(function () {
// $("body").css("backgroundColor", "black");
// });
// }); $(function () {
var btnArr = document.getElementsByTagName("button");
$(btnArr[0]).click(function () {
$("body").get(0).style.backgroundColor = ""; });
$(btnArr[1]).click(function () {
$("body")[0].style.backgroundColor = "black"; });
});
</script>
</head>
<body>
<button>开灯</button>
<button>关灯</button>
<div></div>
</body>
</html>

jQuery——开关灯的更多相关文章

  1. jquery开关灯

    <!DOCTYPE html><html lang="en" xmlns="http://www.w3.org/1999/xhtml"> ...

  2. jQuery之开关灯示例

    准备jquery-3.2.1.js文件 <!DOCTYPE html> <html lang="en"> <head> <meta cha ...

  3. Python 学习第十七天 jQuery

    一,jQuery 知识详解 利用jquery 查找元素,操作元素 1,jquery 引入 <!DOCTYPE html> <html lang="en"> ...

  4. Python之路-jQuery

    参考网址:http://jquery.cuishifeng.cn/ 1.安装环境 2.查找元素 3.操作元素 一.安装环境: 1.我们需要去官网下载jQuery,地址:http://jquery.co ...

  5. jQuery编程基础精华02(属性、表单过滤器,元素的each,表单选择器,子元素过滤器(*),追加方法,节点,样式操作)

    属性.表单过滤器 属性过滤选择器: $("div[id]")选取有id属性的<div> $("div[title=test]")选取title属性为 ...

  6. 静态Web开发 JQuery

    伍章 JQuery 1节介绍JQuery和顶级对象 <<锋利的JQuery>>JQuery官网: http://jquery.com (下载jquery工具)JQuery在线A ...

  7. Jquery方法大全

    一.JQuery常用的方法 :(JQuery中90%都是方法,没有参数是获取,带参数是设置) $("#id").css('backgroundColor','blue'); .cs ...

  8. Jquery 方法大全

    一.JQuery常用的方法 :(JQuery中90%都是方法,没有参数是获取,带参数是设置) $("#id").css('backgroundColor','blue'); .cs ...

  9. 大爱jQuery,10美女模特有用jQuery/CSS3插入(集成点免费下载)

    整合下载地址:http://download.csdn.net/detail/yangwei19680827/7343001 jQuery真的是一款非常犀利的Javascript框架,利用jQuery ...

随机推荐

  1. Codeforces 303A(构造)

    题意:对0到(n-1)这n个数进行全排列.请找出三个全排列a.b.c,使得“a与b的对应元素的和”与“c的对应元素”对模n同余,无解输出-1.(n<=1e5) 分析:n为奇数有解,n为偶数无解 ...

  2. Codeforces Round #391(div 1+2)

    A =w= B QuQ C 题意:有n个体育场,每个体育场有一些小精灵,一共m种小精灵(n<=1e5,m<=1e6),可以将数字全为i的精灵进化成j(可以互相进化也可以选择不进化),问有多 ...

  3. 在Spring MVC和Spring Boot中使用thymeleaf模板

    Spring MVC: POM: <!-- thymeleaf模板 --> <!-- https://mvnrepository.com/artifact/org.thymeleaf ...

  4. Linux: 查找使用中的port

    找出所有使用中的port netstat -tulpn 输出 Active Internet connections (only servers) Proto Recv-Q Send-Q Local ...

  5. JFrame实现批量获取Android安装包安全证书MD5

    今天遇到一个需求.获取全部apk的签名的MD5.以下是我使用Java SE实现的一个工具.贴出核心源码.希望给有须要的朋友有所帮助. 界面例如以下: 仅仅须要制定.apk文件所在的文件夹就可以,核心代 ...

  6. SQL语句多表连接查询语法

    一.外连接 1.左连接  left join 或 left outer join SQL语句:select * from student left join score on student.Num= ...

  7. iOS 中删除cookie的正确做法

    需求:删除 qq 登录的 cookie,保证下次打开 qq 登录页面不会默认登录 实现:      NSString *url =@"https://w.mail.qq.com/cgi-bi ...

  8. hdu 5325 Crazy Bobo dfs

    // hdu 5325 Crazy Bobo // // 题目大意: // // 给你一棵树,树上每一个节点都有一个权值w,选择尽可能多的节点, // 这些节点相互联通,而且依照权值升序排序之后得到节 ...

  9. Codeforces Round #250 (Div. 2)B. The Child and Set 暴力

    B. The Child and Set   At the children's day, the child came to Picks's house, and messed his house ...

  10. oc69--NSMutableString

    // main.m // NSMutableString基本概念,NSString是不可变字符串,NSMutableString是可变字符串.NSMutableString继承NSString,所以N ...