作品第一课----改变DIV样式属性
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style type="text/css">
.btn { margin: 0 auto; padding-left: 30%;}
.img { width: 200px; height: 200px; margin: 10% 30%; background-color: #000; } </style>
<script src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
</head>
<body>
<div class="btn">
<input type="button" class="be_width" value="变宽">
<input type="button" class="be_height" value="变高">
<input type="button" class="be_color" value="变色">
<input type="button" class="be_hide" value="隐藏">
<input type="button" class="be_reset" value="重置">
</div> <div class="img"> </div>
<script>
var width = $(".img").css('width');
var height = $(".img").css('height');
var color = $(".img").css('background-color'); var new_width = parseInt(width) + 200 + 'px';
var new_height = parseInt(height) + 200 + 'px';
console.log(new_width);
$(".be_width").on("click", function() {
$(".img").css("width", new_width);
}); $(".be_height").on("click", function(){
$(".img").css("height", new_height);
}); $(".be_color").on("click", function(){
$(".img").css("background-color", "red");
}); $(".be_hide").on("click", function(){
$(".img").hide();
}); $(".be_reset").on("click", function(){
$(".img").show().css({"width": "200px", "height": "200px", "background-color": "#000"}); }); </script>
</body>
</html>
作品第一课----改变DIV样式属性的更多相关文章
- 函数传参,改变Div任意属性的值&&图片列表:鼠标移入/移出改变图片透明度
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- 封装函数通过输入(元素,属性,目标值)改变div样式
## 假设一个div样式如下```html<!DOCTYPE html><html lang="en"> <head> <meta cha ...
- vue踩坑之路--点击按钮改变div样式
有时候,我们在做项目的时候,想通过某个按钮来改变某个div样式,那么可以通过以下代码实现: <!DOCTYPE html> <html> <head> <me ...
- 作品第一课----循环改变DIV颜色
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- JavaScript第一天 改变DIV的样式
onmouseover 当鼠标移到这个对象之上时响应 onmouseout 当鼠标移出这个对象之上时响应 document.getElementById('id') 获取id的元素并可以做一些操作 ...
- 作品第一课----获取批量checkbox选中的值
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- JS学习笔记 - fgm练习 - 鼠标移入/移出div样式改变
思路: div的默认样式正常设置. 鼠标移入时,发生改变的样式有3个,即 边框颜色,div背景色,字体颜色. 把这三个css改变设置在一个类名下,再通过js给div动态 添加/去除这个类名,实现div ...
- 【JavaScript从入门到精通】第一课 初探JavaScript魅力-01
第一课 初探JavaScript魅力-01 JavaScript是什么 如今我们打开一个大型的网站,都会有很多JS效果的功能和应用.对于学过CSS+HTML的同学,即使是像淘宝那样的网站,用一两天时间 ...
- 【JavaScript从入门到精通】第一课
第一课 初探JavaScript魅力-01 JavaScript是什么 如今我们打开一个大型的网站,都会有很多JS效果的功能和应用.对于学过CSS+HTML的同学,即使是像淘宝那样的网站,用一两天时间 ...
随机推荐
- File的文件提取的小练习
package com.java.Dmeo1.www; import java.io.File;import java.util.LinkedList;import java.util.TreeSet ...
- GitHub Windows客户端部署
下载网址:https://windows.github.com 点击下载按钮即可下载一个小程序,这个小程序会去服务器端下载完整的Windows版客户端,然后自动安装. 如果安装出错的话,那就打开IE浏 ...
- Headfirst设计模式的C++实现——简单工厂模式(Simple Factory)
Pizza.h #ifndef _PIZZA_H #define _PIZZA_H #include <iostream> #include <string> class Pi ...
- python的一些学习资料(持续更新中)
Markdown在线编辑器 廖雪峰官方博客[基础入门好资料] python-guide[传说中的巨牛写的] the5fire的技术博客[全职python程序员博客]
- CodeFirst数据库迁移小记
打开“程序包管理器控制台”菜单项一.Enable-Migrations -ContextTypeName Code_First_数据迁移.Models.T_DbContext成功后提示:已在项目“Co ...
- Excel下拉框选项切换行颜色切换
选择行颜色变化范围 开始-条件格式-新创建规则-"使用公式-" 录入:=$104B="确认" 点击"格式(F)-"->填充,选择填充颜 ...
- 什么是xsi:type ???
http://www.w3.org/2001/XMLSchema-instance http://help.eclipse.org/indigo/index.jsp?topic=%2Forg.ecli ...
- python之---类和实例
类和实例: 面向对象最重要的概念就是类(Class)和实例(Instance),必须牢记类是抽象的模板,比如Student类,而实例是根据类创建出来的一个个具体的“对象”,每个对象都拥有相同的方法,但 ...
- What does it mean for an algorithm to be fair
What does it mean for an algorithm to be fair In 2014 the White House commissioned a 90-day study th ...
- matlab学习笔记(一)单元数组
matlab学习笔记(一)单元数组 1.floor(x) :取最小的整数 floor(3.18)=3,floor(3.98)=3 ceil(x) :取最大的整数 ceil(3.18)=4,ceil( ...