手机网页中的hover效果实现

12/6/2015来源:Javascript教程人气:1072

js文件

function mouSEOut(obj) {
      
    var className ="hover";
      
    var _ecname = obj.className;
      
    if (_ecname.length == 0) return;
      
    if (_ecname == className) {
       
    obj.className ="";return;
      
    }
    if (_ecname.match(new RegExp("(^|\s)"+ className +"(\s|$)")))
       
    obj.className = _ecname.replace((new RegExp("(^|\s)"+ className +"(\s|$)")),"");
     
    }  
    function hover(obj) {
      
    if (!obj) return;
      
    var className ="hover"
      var _ecname = obj.className;
      
    if (_ecname.length == 0) {
       
    obj.className = className;return;
      
    }
      
    if (_ecname == className || _ecname.match(new RegExp("(^|\s)"+ className +"(\s|$)")))
       return;
      
    obj.className = _ecname +""+ className;
     
    } 

引用

<script>
$(function () {
     
$(".wrapper .record .r-main .r-more a").attr('ontouchstart', 'hover(this)');
//hover效果
     
$(".wrapper .record .r-main .r-more a").attr('ontouchend', 'mouseout(this)');
//秒除hover
 
})
 
	
</script>