Javascript 仅用于触摸设备防止滚动定位链接
我有一个固定的链接Javascript 仅用于触摸设备防止滚动定位链接,javascript,coffeescript,Javascript,Coffeescript,我有一个固定的链接 <a href="#location">Link 1</a> 咖啡剧本 $('#clientMenuButton').click(function(e) { if ($('html.touch').length > 0) { e.preventDefault(); $('#mobileClientList').fadeToggle('slow'); } else { $("html, body").animate
<a href="#location">Link 1</a>
咖啡剧本
$('#clientMenuButton').click(function(e) {
if ($('html.touch').length > 0) {
e.preventDefault();
$('#mobileClientList').fadeToggle('slow');
} else {
$("html, body").animate({
scrollTop: $($.attr(this, "href")).offset().top
}, 500);
return false;
}
});
$('#clientMenuButton').click (e) ->
if $('html.touch').length > 0
e.preventDefault()
$('#mobileClientList').fadeToggle 'slow'
return
else
$("html, body").animate
scrollTop: $($.attr(this, "href")).offset().top
, 500
false