jq
// window.onscroll事件(Y一定是大写)
window.onscroll = function() {
console.log(scrollY);
if (scrollY > 800) {
document.getElementById('ret').style.display = 'block';
} else {
document.getElementById('ret').style.display = 'none';
}
}
document.getElementById('ret').onclick = function() {
window.scrollTo(0, 0);
}
// // parentNode:父级节点
// childNodes: 子级节点集
// firstChild: 第一个子级节点
// lastChild: 最后一个子级节点
// nextSibling: 同级下一个节点
// previousSibling: 同级上一个节点,
document.getElementById('bd').onclick=function(e){
alert('1');
// e.stopPropagation()只执行当前这个,不执行他的父级
e.stopPropagation();
// return false加在a里面会阻止a标签默认的跳转,在jq里面既阻止默认又不执行他的父级
// event.preventDefault();取消事件的默认动作;
return false;
}
document.getElementById('ips').onclick=function(){
alert('2')
}
//
$('ul li').hover(function(){
$(this).css('color','blue');
},function(){
$(this).css('color','green');
});
浙公网安备 33010602011771号