引入JQ,使用以下代码。
$(document).ready(function() {
$('a').on('click touchend', function(e) {
var el = $(this);
var link = el.attr('href');
window.location = link;
});
});这样的话其实会出现一个问题,只要触摸经过,就会跳转。
那我们也可以指定某些CLASS类有这个功能。
例如:只指定了.more-btn和.foot-link
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
// 只为类为 more-btn 和 foot-link 的链接绑定事件
$('.more-btn, .foot-link').on('click touchend', function(e) {
var el = $(this);
var link = el.attr('href');
window.location = link;
});
});
</script>