javascriptは事件の泡が立つことを阻止します。

745 ワード

イベント勃発を阻止する
event.prevent Default()イベントを阻止するデフォルト動作
<!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>