阻止表单提交刷新页面的问题

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1"><meta http-equiv="X-UA-Compatible" content="IE=edge" />

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>
Marker Animation
</title>
<style type="text/css">
html, body, #map, #form1 {
margin: 0;
padding: 0;
width: 100%;
height: 80%;
}

body, div, ul, li {
margin: 0;
padding: 0;
}
</style>

</head>
<body>
<form method="post"  id="form1">

 <button id="start-animation">Start Animation</button>

  <script>

 var startButton = document.getElementById('start-animation');

function startAnimation() {
event.preventDefault();

}

startButton.addEventListener('click', startAnimation, false);

</script>

<form>

 

posted @ 2018-05-24 14:03  风无心客  阅读(348)  评论(0编辑  收藏  举报