首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

javascript 遏止事件冒泡

2012-09-12 
javascript 阻止事件冒泡event.stopPropagation() 阻止事件冒泡event.preventDefault() 阻止事件的默认动

javascript 阻止事件冒泡

event.stopPropagation() 阻止事件冒泡

event.preventDefault() 阻止事件的默认动作

<!DOCTYPE html><html><head>  <script src="http://code.jquery.com/jquery-latest.js"></script></head><body>  <a href="http://jquery.com">default click action is prevented</a><div id="log"></div><script>$("a").click(function(event) {  event.preventDefault();  $('<div/>')    .append('default ' + event.type + ' prevented')    .appendTo('#log');});</script></body></html>
?

?

热点排行