js阻止a标签默认跳转
函数:
// 阻止默认跳转
function stopDefault( e ) {
if ( e && e.preventDefault )
e.preventDefault();
else
window.event.returnValue = false;
return false;
}
使用示例:
// 阻止所有a标签的跳转
$(document).ready(function(){
$(document).on('click','a',function(e){
stopDefault(e);
});
});