<!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>
&lt;script type="text/javascript"&gt;
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>
&lt;/script&gt;
</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函数——设置/读取对象的属性&&当前输入框高亮显的更多相关文章

  1. NLR:利用非线性回归,梯度下降法求出学习参数θ,进而求得Cost函数最优值——Jason niu

    import numpy as np import random def genData(numPoints,bias,variance): x = np.zeros(shape=(numPoints ...

  2. javascript 在一个函数参数中包含另一个函数的引用

    javascript函数的参数包含另一个函数的情形: <script> //b函数的参数func为另一个函数 function b(a, func) {  alert(a); //调用参数 ...

  3. python基础-4 函数参数引用、lambda 匿名函数、内置函数、处理文件

    上节课总结 1.三元运算 name=“name1”if 条件 else “name2” 2.深浅拷贝 数字.字符串 深浅,都一样 2.其他 浅拷贝:只拷贝第一层 深拷贝:不拷贝最后一层 3.set集合 ...

  4. c++函数参数或返回值为函数指针

    C++中函数指针的形式为:返回值类型 + 参数类型,函数没有值类型,但是却可以声明函数的指针,因为函数是可寻址的,存放在内存中的代码段,可以从指针访问. 函数指针可以声明为: void (*pF)(v ...

  5. OpenJudge计算概论-求出e的值

    /*======================================================================== 求出e的值 总时间限制: 1000ms 内存限制: ...

  6. C++数组(指针)作为函数参数

    本文的学习内容参考:http://blog.csdn.net/wwdlk/article/details/6322843 1.当用数组名作为函数参数时,函数的实参和形参都应为数组名(或者指针): Ex ...

  7. C++解析(6):函数参数的扩展

    0.目录 1.函数参数的默认值 2.函数默认参数的规则 3.函数占位参数 4.小结 1.函数参数的默认值 C++可以在函数声明时为参数提供一个默认值 当函数调用时没有提供参数的值,则使用默认值 参数的 ...

  8. ES6函数参数默认值作用域的模拟原理实现与个人的一些推测

    一.函数参数默认值中模糊的独立作用域 我在ES6入门学习函数拓展这一篇博客中有记录,当函数的参数使用默认值时,参数会在初始化过程中产生一个独立的作用域,初始化完成作用域会消失:如果不使用参数默认值,不 ...

  9. 根据SVG Arc求出其开始角、摆动角和椭圆圆心

    SVG Arc 目前Svg的Arc的参数字符串如下: a rx ry x-axis-rotation large-arc-flag sweep-flag x y 除了a表示标识为Arc之外,其余参数说 ...

随机推荐

  1. sql 取一张表的全部外键

    select a.name as 约束名, object_name(b.parent_object_id) as 外键表, d.name as 外键列, object_name(b.reference ...

  2. YYH的球盒游戏(NOIP模拟赛Round 6)

    题目描述 YYH有一些总共有种颜色的球,他有颜色的球个.他同样有个盒子,第个盒子能放个球. 他的目标是把这个球按规则放进个盒子里: 对于一个盒子,对于每种颜色的球至多只能放个. 把颜色为的球放进盒子, ...

  3. 在iOS上实现一个简单的日历控件

    http://blog.csdn.net/jasonblog/article/details/21977481 近期需要写一个交互有点DT的日历控件,具体交互细节这里略过不表. 不过再怎么复杂的控件, ...

  4. Android屏幕元素层次结构

    转自:http://blog.csdn.net/hpoi/article/details/4629717   Android屏幕元素层次结构 android.app.Activity 对于一个Andr ...

  5. Java进阶之路,技术要点

    宏观方面 一.JAVA.要想成为JAVA(高级)工程师肯定要学习JAVA.一般的程序员或许只需知道一些JAVA的语法结构就可以应付了.但要成为JAVA(高级)工程师,您要对JAVA做比较深入的研究.您 ...

  6. Java微信公众平台开发_01_本地服务器映射外网

    做微信开发之前,我们需要先做一个内网穿透,让我们的工程可以在公网上被访问. 一.工具列表 内网穿透的相关工具有: (1)natapp 官网 :https://natapp.cn/ (2)花生壳 官网: ...

  7. [BZOJ1018][SHOI2008]堵塞的交通traffic 线段树维护连通性

    1018: [SHOI2008]堵塞的交通traffic Time Limit: 3 Sec  Memory Limit: 162 MB Submit: 3795  Solved: 1253 [Sub ...

  8. NYOJ 21.三个水杯-初始态到目标态的最少次数-经典BFS

    题目传送门:biubiubiu~ 三个水杯 时间限制:1000 ms  |  内存限制:65535 KB 难度:4   描述 给出三个水杯,大小不一,并且只有最大的水杯的水是装满的,其余两个为空杯子. ...

  9. Codeforces Round #449 (Div. 2) A. Scarborough Fair【多次区间修改字符串】

    A. Scarborough Fair time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  10. 2018 JUST Programming Contest 1.0 题解

    题目链接  gym101778 Problem A 转化成绝对值之后算一下概率.这个题有点像 2018 ZOJ Monthly March Problem D ? 不过那个题要难一些~ #includ ...