javascript StyleSheet样式操作类
早上在csdn上看有人问页面style sheet怎么修改里面的rule,就写了个类,该类对兼容FF和IE做了处理。
/**//*--------------------------------------------
描述 : 添加新的样式rule
参数 : styleSheets索引
代码 : var ss = new styleSheet(0);
--------------------------------------------*/
var styleSheet = function(n)
...{
var ss;
if (typeof n == "number") ss = document.styleSheets[n];
this.sheet = ss;
this.rules = ss.cssRules?ss.cssRules:ss.rules;
};
/**//*--------------------------------------------
描述 : 查找样式rule,成功返回index,否则返回-1
参数 : n为rule名称
代码 : var ss = new styleSheet(0);
ss.indexOf("className")
--------------------------------------------*/
styleSheet.prototype.indexOf = function(selector)
...{
for(var i=0;i<this.rules.length;i++)
...{
if(this.rules[i].selectorText==selector)
...{
return i;
}
}
return -1;
};
/**//*--------------------------------------------
描述 : 删除样式rule
参数 : n为rule索引或者名称
代码 : var ss = new styleSheet(0);
ss.rem
相关文档:
在数据绑定事件中写如下代码:
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row .RowType == DataControlRowType .DataRow)//判断是否为数据行
{
//在点击删除时,弹出提示对话框
LinkButton lb = e.Row.FindControl("LinkB ......
事件源对象
event.srcElement.tagName
event.srcElement.type
捕获释放
event.srcElement.setCapture();
event.srcElement.releaseCapture();
事件按键
event.keyCode
event.shiftKey
event.altKey
event.ctrlKey
事件返回值
event.returnValue
鼠标位置
event.x
event.y
窗体 ......
预定时间之后执行函数
setTimeout("functionname",interval)
提取字符串中数值信息
parseInt(string)
复制节点(是否复制子节点)
cloneNode(true/false)
删除子节点
removeChild()
替换节点
replaceChild(newChild,oldChild)
子节点判断
hasChildNodes ......
返回一个给定id属性值的元素节点的对象
document.getElememtById(id)
返回一个包含所有给定标签的元素的数组
document.getElementsByName(tag)
获取元素属性
document.getAttribute(attribute)
设置元素属性值
document.setAttribute(attribute)
......
1、rcbdyctl
view plaincopy to clipboardprint?
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=gb2312">
<title>JS获取客户端IP</title>
</head>
<b ......