css 脚本解释

html-css012

css 脚本解释,第1张

//声明函数startList()

startList = function() {

//如果浏览器支持DOM

if (document.all&&document.getElementById) {

//将id为nav的元素赋给变量navRoot,(貌似这个navRoot是全局变量,不然要用var声明)

navRoot = document.getElementById("nav")

//定义一个循环,循环变量i的上限是id为nav的元素的字节点数量,此时navRoot的子节点的集合是数组,i自加1

for (i=0i<navRoot.childNodes.lengthi++) {

//将数组navRoot.childNodes下标索引为i的元素赋给变量node

node = navRoot.childNodes[i]

//如果node的标签的是LI

if (node.nodeName=="LI") {

//当鼠标移动到这个LI标签上时触发以下函数

node.onmouseover=function() {

//这句相当于this.className = this.className + " over",className是其class属性对应的css类名

this.className+=" over"

}

//当鼠标离开该元素时出发以下函数

node.onmouseout=function() {

//此时元素的class属性中的" over"被""替换,""表示空

this.className=this.className.replace(" over", "")

}

}

}

}

}

//当页面读取时,触发startList函数

window.onload=startList

qlikSense可以写CSS脚本来调节样式:

一、使用STYLE属性:将STYLE属性直接加在个别的元件标签里。

二、使用STYLE标签:将样式规则写在<STYLE>...</STYLE>标签之中。

三、使用 LINK标签:将样式规则写在.css的样式中,再以<LINK>标签引入。

四、使用@import引入:跟LINK用法很像,但必 放在<STYLE>...</STYLE>中。