1.获取滚动条高度
var top=document.body.scrollTop||document.documentElement.scrollTop;
2.事件监听
var addEvent = function (obj, ev ,fn)
{
if(obj.attachEvent){
obj.attachEvent('on'+ev, fn);
}else{
obj.addEventListener(ev, fn, false);
}
};
3.事件移除
var removeEvent = function(element, type, handler){
if (element.removeEventListener) {
element.removeEventListener(type, handler, false);
}
else if (element.detachEvent) {
element.detachEvent("on" + type, handler);
}
else {
element["on" + type] = null;
}
}
4.阻止默认事件
function(event){
if (event.preventDefault) {
event.preventDefault();
}
else {
event.returnValue = false;
}
}
5.阻止事件冒泡
function(event){
if (event.stopPropagation) {
event.stopPropagation();
}
else {
event.cancelBubble = true;
}
}
6.元素的子节点
var getChildNode=function(obj)
{
var childArr = [];
var l=obj.childNodes.length;
for (var i=0;i<l;i++)
{
if(obj.childNodes[i].nodeType==1)
{
childArr.push(obj.childNodes[i]);
}
}
return childArr;
}