<script> var link = document.getElementById('link'); console.log(link); link.addEventListener('click',function(e) { alert('夜幕');// return false;//在這種情況下阻止不了,// e.preventDefault() }) document.body.onclick = function () { prompt('shi'); return false; removeEventListener }// link.onclick = function (e) {// alert('夜幕');// return false;//在這種情況下可以阻止//// e.preventDefault()// }</script>為什么用body才能取消跳轉???冒泡到body上嗎?
JavaScript冒泡嗎?
慕尼黑8549860
2019-02-08 18:13:24