jQuery——开关灯
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——开关灯的更多相关文章
- jquery开关灯
<!DOCTYPE html><html lang="en" xmlns="http://www.w3.org/1999/xhtml"> ...
- jQuery之开关灯示例
准备jquery-3.2.1.js文件 <!DOCTYPE html> <html lang="en"> <head> <meta cha ...
- Python 学习第十七天 jQuery
一,jQuery 知识详解 利用jquery 查找元素,操作元素 1,jquery 引入 <!DOCTYPE html> <html lang="en"> ...
- Python之路-jQuery
参考网址:http://jquery.cuishifeng.cn/ 1.安装环境 2.查找元素 3.操作元素 一.安装环境: 1.我们需要去官网下载jQuery,地址:http://jquery.co ...
- jQuery编程基础精华02(属性、表单过滤器,元素的each,表单选择器,子元素过滤器(*),追加方法,节点,样式操作)
属性.表单过滤器 属性过滤选择器: $("div[id]")选取有id属性的<div> $("div[title=test]")选取title属性为 ...
- 静态Web开发 JQuery
伍章 JQuery 1节介绍JQuery和顶级对象 <<锋利的JQuery>>JQuery官网: http://jquery.com (下载jquery工具)JQuery在线A ...
- Jquery方法大全
一.JQuery常用的方法 :(JQuery中90%都是方法,没有参数是获取,带参数是设置) $("#id").css('backgroundColor','blue'); .cs ...
- Jquery 方法大全
一.JQuery常用的方法 :(JQuery中90%都是方法,没有参数是获取,带参数是设置) $("#id").css('backgroundColor','blue'); .cs ...
- 大爱jQuery,10美女模特有用jQuery/CSS3插入(集成点免费下载)
整合下载地址:http://download.csdn.net/detail/yangwei19680827/7343001 jQuery真的是一款非常犀利的Javascript框架,利用jQuery ...
随机推荐
- 最大公约数GCD
基准时间限制:1 秒 空间限制:131072 KB 分值: 0 难度:基础题 输入2个正整数A,B,求A与B的最大公约数. Input 2个数A,B,中间用空格隔开.(1<= A,B <= ...
- MySQL主从复制邮件报警脚本
#!/bin/shexport PATH=$PATH:/application/mysql/3306/binlogFile=`date +"%Y-%m-%d %H:%M:%S"`_ ...
- FreeMarker与Servlet结合示例
一.最原始示例 1.引入POM依赖 <!-- https://mvnrepository.com/artifact/org.freemarker/freemarker --> <de ...
- Servlet通过JavaBean传值到JSP页面
主要通过Attribute进行传递,主要代码如下: 赋值,并定义跳转的页面: request.setAttribute("user", user); request.getRequ ...
- Workflow:添加工作流存储功能
数据库准备: 1. 创建database(这里我们用的是MSSQL.Workflow支持其它数据库,但是MSSQL是配置最方便,不要问我为什么!). 2. 运行位于[%WINDIR%\Microsof ...
- Android应用程序相关的文件文件夹具体解释
一.方法介绍: 每一个Android应用程序都能够通过Context来获取与应用程序相关的文件夹,这些文件夹的功能各异,每一个文件夹都有自己的特点.有时候可能会搞混淆,本文结合andr ...
- cc2540 usbdongle 安装驱动失败的终极解决方法 【原创,多图】
Ghost winxp win7系统安装CC2540 usbdongle CDC驱动程序 [重要提示] 因为非常多朋友使用Ghost系统.导致安装cdc驱动时安装不成功,出现 "INF中的服 ...
- POJ 2367:Genealogical tree(拓扑排序)
Genealogical tree Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 2738 Accepted: 1838 Spe ...
- LeetCode 290. Word Pattern (词语模式)
Given a pattern and a string str, find if str follows the same pattern. Here follow means a full mat ...
- 如何在 webpack 项目中使用绝对路径
react 小白编程 本项目是使用 create-react-app 脚手架构建的react项目 找到 config 配置文件下的 webpack.config.dev.js 和 webpack.co ...