封装函数

// 阻止默认跳转
function stopDefault(e) {
    if (e&&e.preventDefault){
        e.preventDefault();
    }else{
        window.event.returnValue = false;
        return false;
    }
}

函数调用

//方法一
$(document).ready(function(){
    $(document).on('click','a',function(e){
        stopDefault(e);
    });
});
//mui-app方法
mui('#newsContent').on('tap', 'a', function(e) {
    stopDefault(e);
});

最后修改:2019 年 11 月 28 日
如果觉得我的文章对你有用,请随意赞赏