agruments应用——求出函数参数的总合&&css函数——设置/读取对象的属性&&当前输入框高亮显
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>agruments应用——求出函数参数的总合</title>
<style>
pre{color:green;padding:10px 15px;background:#f0f0f0;border:1px dotted #333;font:12px/1.5 Courier New;}
span{color:#999;}
</style>
</head>
<body>
<pre>
<script type="text/javascript">
var i = iResult = 0
function sum()
{
for (var i = 0; i < arguments.length; i++)
{
iResult += arguments[i]
}
return iResult
}
<span>//应用</span>
alert(sum(1,2,3,4,5,6,7,8,9,10)) <span>//输出55</span>
</script>
</pre>
<script type="text/javascript">
var i = iResult = 0
function sum()
{
for (var i = 0; i < arguments.length; i++)
{
iResult += arguments[i]
}
return iResult
}
//应用
alert(sum(1,2,3,4,5,6,7,8,9,10))
</script>
</body>
</html>
css函数——设置/读取对象的属性
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>css函数——设置/读取对象的属性</title>
<style>
div{width:400px;height:200px;background:#fef4eb;border:1px solid #f60;margin:0 auto;}
input{border:0;color:#fff;cursor:pointer;font-weight:700;background:#f60;padding:2px 4px;margin:10px 0 0 10px;}
</style>
<script type="text/javascript">
function css(obj, attr, value)
{
switch (arguments.length)
{
case 2:
if(typeof arguments[1] == "object")
{ //二个参数, 如果第二个参数是对象, 批量设置属性
for (var i in attr)obj.style[i] = attr[i]
}
else
{ //二个参数, 如果第二个参数是字符串, 读取属性值
return obj.currentStyle ? obj.currentStyle[attr] : getComputedStyle(obj, null)[attr]
}
break;
case 3:
//三个参数, 单一设置属性
obj.style[attr] = value;
break;
default:
alert("参数错误!")
}
}
window.onload = function ()
{
var oBox = document.getElementById("box");
var aInput = oBox.getElementsByTagName("input"); //第一个按钮点击事件
aInput[0].onclick = function ()
{
//两个参数, 第二个参数为字符串, 读取属性值
alert("width: " + css(oBox, "width") + "\nheight: " + css(oBox, "height") + "\nbackground-color: " + css(oBox, "backgroundColor"))
};
//第二个按钮点击事
aInput[1].onclick = function ()
{
//两个参数, 第二个参数为对象, 属性批量设置
css(oBox, {width: "330px", height: "100px", borderColor: "#0084ff", backgroundColor: "#eff8ff"});
//三个参数, 属性单一设置
for (i = 0; i < aInput.length; i++) css(aInput[i], "backgroundColor", "#0084ff")
}
//第三个按钮点击事件
aInput[2].onclick = function ()
{
//两个参数, 第二个参数为对象, 属性批量设置
css(oBox, {width: "400px", height: "200px", borderColor: "#f60", backgroundColor: "#fef4eb"});
//三个参数, 属性单一设置
for (i = 0; i < aInput.length; i++) css(aInput[i], "backgroundColor", "#f60")
}
};
</script>
</head>
<body>
<div id="box">
<input type="button" value="Get Style" /><input type="button" value="Set Style" /><input type="button" value="Default Style" />
</div>
</body>
</html>
当前输入框高亮显
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>当前输入框高亮显示</title>
<style>
body,form,h2,p,input{margin:0;padding:0;}
body{color:#4f4f4f;font:14px/1.5 \5fae\8f6f\96c5\9ed1;}
form{width:400px;background:#fef4eb;border:2px solid #f60;padding-bottom:10px;overflow:hidden;zoom:1;margin:10px auto;}
form h2{color:#fe791e;font-size:16px;background:#ffebd7;border-bottom:2px solid #f60;padding:5px 10px;}
form p{float:left;clear:both;width:100%;height:31px;margin-top:10px;line-height:31px;}
form label,form input{float:left;}
form label{width:100px;height:31px;text-align:right;}
form input{border:0;font-family:\5fae\8f6f\96c5\9ed1;background:url(img/input.png) no-repeat;}
form .f-text,form .f-text-high{width:203px;height:31px;padding-left:5px;line-height:31px;}
form .f-text-high{background-position:0 -31px;}
form .f-btn{color:#fff;width:104px;height:31px;cursor:pointer;font-size:16px;background:#f60;line-height:31px;border-radius:5px;}
</style>
<script type="text/javascript">
window.onload = function ()
{
var aInput = document.getElementsByTagName("input");
var i = 0;
for (i = 0; i < aInput.length - 1; i++)
{
aInput[i].onfocus = function ()
{
this.className = "f-text-high"
};
aInput[i].onblur = function ()
{
this.className = "f-text"
}
}
};
</script>
</head>
<body>
<form>
<h2>用户登录</h2>
<p><label>用户名:</label><input class="f-text" type="text" /></p>
<p><label>密码:</label><input class="f-text" type="password" /></p>
<p><label></label><input class="f-btn" type="button" value="登 录" /></p>
</form>
</body>
</html>
agruments应用——求出函数参数的总合&&css函数——设置/读取对象的属性&&当前输入框高亮显的更多相关文章
- NLR:利用非线性回归,梯度下降法求出学习参数θ,进而求得Cost函数最优值——Jason niu
import numpy as np import random def genData(numPoints,bias,variance): x = np.zeros(shape=(numPoints ...
- javascript 在一个函数参数中包含另一个函数的引用
javascript函数的参数包含另一个函数的情形: <script> //b函数的参数func为另一个函数 function b(a, func) { alert(a); //调用参数 ...
- python基础-4 函数参数引用、lambda 匿名函数、内置函数、处理文件
上节课总结 1.三元运算 name=“name1”if 条件 else “name2” 2.深浅拷贝 数字.字符串 深浅,都一样 2.其他 浅拷贝:只拷贝第一层 深拷贝:不拷贝最后一层 3.set集合 ...
- c++函数参数或返回值为函数指针
C++中函数指针的形式为:返回值类型 + 参数类型,函数没有值类型,但是却可以声明函数的指针,因为函数是可寻址的,存放在内存中的代码段,可以从指针访问. 函数指针可以声明为: void (*pF)(v ...
- OpenJudge计算概论-求出e的值
/*======================================================================== 求出e的值 总时间限制: 1000ms 内存限制: ...
- C++数组(指针)作为函数参数
本文的学习内容参考:http://blog.csdn.net/wwdlk/article/details/6322843 1.当用数组名作为函数参数时,函数的实参和形参都应为数组名(或者指针): Ex ...
- C++解析(6):函数参数的扩展
0.目录 1.函数参数的默认值 2.函数默认参数的规则 3.函数占位参数 4.小结 1.函数参数的默认值 C++可以在函数声明时为参数提供一个默认值 当函数调用时没有提供参数的值,则使用默认值 参数的 ...
- ES6函数参数默认值作用域的模拟原理实现与个人的一些推测
一.函数参数默认值中模糊的独立作用域 我在ES6入门学习函数拓展这一篇博客中有记录,当函数的参数使用默认值时,参数会在初始化过程中产生一个独立的作用域,初始化完成作用域会消失:如果不使用参数默认值,不 ...
- 根据SVG Arc求出其开始角、摆动角和椭圆圆心
SVG Arc 目前Svg的Arc的参数字符串如下: a rx ry x-axis-rotation large-arc-flag sweep-flag x y 除了a表示标识为Arc之外,其余参数说 ...
随机推荐
- Installing patches on an ESXi 5.x by the command
Purpose This article outlines the procedure for installing patches on an ESXi 5.x host from the comm ...
- Vitamio 视频播放
资料总结 Vitamio官网:https://www.vitamio.org 源码地址:https://github.com/yixia/VitamioBundle 最佳教程:大名鼎鼎的农民伯伯博客 ...
- scrapy爬取段子
scrapy.py 1.cmd运行scrapy shell http://www.baidu.com response.xpath('//div[@aa="bb"]') 找到需要匹 ...
- Instruments Tutorial for iOS: How To Debug Memory Leaks
http://www.raywenderlich.com/2696/instruments-tutorial-for-ios-how-to-debug-memory-leaks Update 4/12 ...
- android的百度地图开发(一)
1,注册百度开发者账号 2,申请key ,注意开发版SH和发布版的SH 获取开发版SHA1: 输入命令:keytool -list -v -keystore debug.keystore,回车输入 ...
- python 实现经典算法
import time start_time = time.clock() list_ = [9, 2, 7, 4, 5, 6, 3, 8, 1] """ # 堆排序(通 ...
- c语言argc argv
转载自 http://blog.csdn.net/yukiooy/article/details/4682989 main(int argc,char *argv[ ]) argv为指针的指针 arg ...
- 纯HTML+CSS写出一颗会飘动的树,有没有惊艳到你呢?
前言 使用HTML+CSS能写出什么惊人的效果呢? 针对这个问题,我总会看到类似的回答,比如没有JS,前端永远都是静态的:HTML5要搭配JS,要不然一文不值. JS固然强大,但CSS也并非一文不值, ...
- (7)java基础知识-原码、反码、补码、运算符
一.原码.反码.补码 原码 一个数转化成二进制. 用最高位来表示正负,最高位为0表示正数,最高位为1表示负数. 例如: short i=5: 因为在java里short占2个字节转化成二进制就是 00 ...
- Python的网络编程[3] -> BOOTP 协议[0] -> BOOTP 的基本理论
BOOTP协议 / BOOTP Protocol 目录 基本理论 BOOTP 与 DHCP 通信流程 数据报文格式 报文加解码实现 1. 基本理论 / Basic Theory BOOTP(Boots ...