js五道经典练习题--第一道
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style>
*{margin: 0;padding: 0;}
body{
font-family: "微软雅黑";
}
.btn{
padding: 6px 8px;
outline: none;
border: 1px solid #fff;
background: blueviolet;
color: #fff;
cursor: pointer;
}
#div{
width: 100px;
height: 100px;
border: 1px solid #333;
}
.mask{
position: absolute;
width: 100%;
height: 100%;
background: rgba(0,0,0,0.5);
left: 0;
top: 0;
display: none;
}
.mask_dialog{
width: 300px;
height: 300px;
background: #fff;
margin: 0 auto;
padding: 20px;
}
.item1{
margin-bottom: 10px;
}
a{
text-decoration: none;
color: #333333;
display: inline-block;
width: 46px;
height: 46px;
border: 1px solid #333333;
text-align: center;
line-height: 46px;
}
a:hover{
background: orange;
}
</style>
</head>
<body>
<h3>
请为下面的DIV添加样式
<button class="btn" id="btn">按钮</button>
</h3>
<div id="div">
</div>
<div class="mask" id="mask">
<div class="mask_dialog">
<div class="item1">
<span>请选择颜色(px)</span>
<a href="javascript:;">红</a>
<a href="javascript:;">蓝</a>
<a href="javascript:;">绿</a>
</div>
<div class="item1">
<span>请选择宽度(px)</span>
<a href="javascript:;">200</a>
<a href="javascript:;">300</a>
<a href="javascript:;">400</a>
</div>
<div class="item1">
<span>请选择高度(px)</span>
<a href="javascript:;">200</a>
<a href="javascript:;">300</a>
<a href="javascript:;">400</a>
</div>
<div class="mask_footer">
<button class="btn" id="cancel">取消</button>
<button class="btn" id="comfire">确定</button>
</div>
</div>
</div>
<script>
var arr = ["red","blue","green","200","300","400","200","300","400"]
var oBtn = document.getElementById("btn")
var oMask = document.getElementById("mask")
var oA = oMask.getElementsByTagName("a")
var oDiv = document.getElementById("div")
var oCancel = document.getElementById("cancel")
var oComfire = document.getElementById("comfire")
oBtn.onclick = function(){
oMask.style.display = "block"
}
for (var i=0;i<oA.length;i++) {
oA[i].index = i
oA[i].onclick = function(){
// alert(this.index)
if(this.index>=0&&this.index<=2){
oDiv.style.background = arr[this.index]
}else if(this.index>=3 && this.index<=5){
oDiv.style.width = arr[this.index]+"px"
}else{
oDiv.style.height = arr[this.index]+"px"
}
}
}
oCancel.onclick = function(){
oDiv.style.background = "#fff"
oDiv.style.width = 100+"px"
oDiv.style.height = 100+"px"
oMask.style.display = "none"
}
oComfire.onclick = function(){
oMask.style.display = "none"
}
</script>
</body>
</html>
js五道经典练习题--第一道的更多相关文章
- js五道经典练习题--第五道成绩列表
<!DOCTYPE html><html> <head> <meta charset="UTF-8"> <title>& ...
- js五道经典练习题--第四道qq好友列表
<!DOCTYPE html><html> <head> <meta charset="UTF-8"> <title>& ...
- js五道经典练习题--第三道实现购物车功能
<!DOCTYPE html><html> <head> <meta charset="UTF-8"> <title>& ...
- js五道经典练习题--第二道仿qq聊天框
<!DOCTYPE html><html> <head> <meta charset="UTF-8"> <title>& ...
- Python经典练习题1:一个整数,它加上100后是一个完全平方数,再加上168又是一个完全平方数,请问该数是多少?
Python经典练习题 网上能够搜得到的答案为: for i in range(1,85): if 168 % i == 0: j = 168 / i; if i > j and (i + j) ...
- 【视频+图文】Java基础经典练习题(一)输出2-100之间的素数,及素数个数
目录 第一题:判断2-100之间有多少个素数,并输出所有素数. 1.视频讲解: 2.思路分析: 代码讲解:以i=4为例 4.为大家准备了彩蛋: 能解决题目的代码并不是一次就可以写好的 我们需要根据我们 ...
- MYSQL经典练习题,熟悉DQL
MYSQL经典练习题 (本练习题可让你熟悉DQL,快速的上手DQL) 首先,先在数据库中建立基本数据库以及表项: DROP DATABASE IF EXISTS `test`; CREATE DATA ...
- 170106、用9种办法解决 JS 闭包经典面试题之 for 循环取 i
闭包 1.正确的说,应该是指一个闭包域,每当声明了一个函数,它就产生了一个闭包域(可以解释为每个函数都有自己的函数栈),每个闭包域(Function 对象)都有一个 function scope(不是 ...
- 用9种办法解决 JS 闭包经典面试题之 for 循环取 i
2017-01-06 Tomson JavaScript 转自 https://segmentfault.com/a/1190000003818163 闭包 1.正确的说,应该是指一个闭包域,每当声明 ...
随机推荐
- C语言中内存分布及程序运行中(BSS段、数据段、代码段、堆栈)
BSS段:(bss segment)通常是指用来存放程序中未初始化的全局变量的一块内存区域.BSS是英文Block Started by Symbol的简称.BSS段属于静态内存分配. 数据段 : ...
- fedora 安装gdal
hese steps worked for me on a Fedora system: 1.) download the 3 files related to oracle instant clie ...
- Spring Boot REST(一)核心接口
Spring Boot REST(一)核心接口 Spring 系列目录(https://www.cnblogs.com/binarylei/p/10117436.html) SpringBoot RE ...
- Partition Array into Disjoint Intervals LT915
Given an array A, partition it into two (contiguous) subarrays left and right so that: Every element ...
- vue 设置button disabled
<button v-bind:disabled="dis" @click="alert">button</button> dis:'' ...
- applicationContext-common.xml]; nested exception is java.lang.NoClassDefFoundError: org/w3c/dom/ElementTraversal
14:59:16,747 ERROR ContextLoader:350 - Context initialization failedorg.springframework.beans.factor ...
- python之排列组合测试
# test permutations and combinations import itertools as it for i in it.combinations('abcd',2): prin ...
- Python 递归函数 详解
Python 递归函数 详解 在函数内调用当前函数本身的函数就是递归函数 下面是一个递归函数的实例: 第一次接触递归函数的人,都会被它调用本身而搞得晕头转向,而且看上面的函数调用,得到的结果会 ...
- mysql 5.7 linux环境下解压安装
在CentOS linux环境安装mysql 一般rpm(或者yum),预编译和源码安装. 如果采用rpm或者yum安装,mysql的数据文件一般存放在/var/lib/mysql目录下,也就是会把d ...
- 统计方形(NOIP1997)
给链接:统计方形 这题是棋盘问题的数据加强版. 其实由于洛谷的数据比较水,所以你把我在棋盘问题题解中写的代码提交,也能AC. 但让给我们来看一个更优的解法. 先给代码: #include<bit ...