/*
* 返回顶部
*<a class="go-top" id="goTop" href="javascript:;"></a>
* 注:a链接需设置背景图片,或者其他可显示的返回顶部
*/
var $t = $( ‘#goTop‘ );
var $h = 320;
if ( !$t.length ) {
return;
}
var handler = function( e ) {
e.preventDefault();
e.stopPropagation();
var $target = e.target;
var $id = $( $target ).attr( ‘id‘ );
if ( $id === ‘goTop‘ ) {
$( window ).scrollTop( 0 );
return false;
}
};
var __init = function( e ) {
if ( $( window ).scrollTop() > $h ) {
$( $t ).css( ‘visibility‘, ‘visible‘ );
} else {
$( $t ).css( ‘visibility‘, ‘hidden‘ );
}
};
__init();
$( window ).off( ‘scroll‘, __init ).on( ‘scroll‘, __init );
$t.off( ‘click‘, handler ).on( ‘click‘, handler );