---
title: "常用示例"
author: "keimon"
date: "2014-01-02T15:20:30Z"
tags: []
categories: ["Web前端"]
slug: "untitled"
draft: false
lastmod: "2014-01-14T11:34:05Z"
id: 1998345
url: "https://keimon.iteye.com/blog/1998345"
---

1）js

//判断滚动停止demo  

var aa = $(window).scrollTop();  
    var tt;  
    var bb = 0;  
    $(window).bind('scroll', function(){  
        bb = $(window).scrollTop();  
        if(tt == null){  
            tt = setInterval(function(){  
                aa = $(window).scrollTop();  
                if(aa == bb){  
                    console.log('滚动停止');  
                    clearInterval(tt);  
                    tt = null;  
                }  
            },1000)  
        }  
    })

 

2）css

/\*chrome禁止选中\*/  
        #mydiv{  
            user-select : none ;  
            touch-callout : none ;  
            user-drag : none ;  
            tap-highlight-color : rgba(0,0,0,0) ;

            -webkit-user-select : none ;  
            -webkit-touch-callout : none ;  
            -webkit-user-drag : none ;  
            -webkit-tap-highlight-color : rgba(0,0,0,0) ;  
        }

3:javascript:void(0);

[1:https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/void?redirectlocale=en-US&redirectslug=JavaScript%2FReference%2FOperators%2Fvoid](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/void?redirectlocale=en-US&redirectslug=JavaScript%2FReference%2FOperators%2Fvoid)

[2:http://www.zhangxinxu.com/wordpress/2013/01/why-use-href-javascript-void0/](http://www.zhangxinxu.com/wordpress/2013/01/why-use-href-javascript-void0/)

When a browser follows a `javascript:` URI, it evaluates the code in the URI and then replaces the contents of the page with the returned value, unless the returned value is `undefined`. The `void` operator can be used to return `undefined`.

```html
<a href="javascript:void(0);">Click here to do nothing</a>
<a href="javascript:void(document.body.style.backgroundColor='green');">Click here for green background</a>
```