阻止/修改事件冒泡和浏览器默认行为

1.阻止事件冒泡

e.stopPropagation()

2.阻止浏览器的默认行为

//1.
return false;
//2.
e.preventDefault()

3.阻止a标签的more跳转

<a href="javascript:void(0)"></a>

4.阻止选中文字

document.onselectstart=new Function(“return false”)

5.阻止拖动图片

document.ondragstart=new Function(“return false”);

6.修改浏览器选中文字的背景颜色

::selected {
    color:#fff;
    background-color:pink;
}

评论

暂无评论