我只是在Semantic UI上探索,我在一种形式中遇到了一个按钮点击事件,我看到了一个奇怪的行为。
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8" />
<title>Semantic UI CDN</title>
<link rel="stylesheet" href="semantic.css" />
<script src="jquery.min.js"></script>
<script src="semantic.js"></script>
</head>
<body style="margin:1em;">
<!-- Your Semantic UI Code -->
<br/><br/>
<h1 class="ui center aligned icon header">
First Form
</h1>
<form class="ui form" style="">
<div class="inline fields" id="ir_num_row_div">
<div class="three wide field required">
<label>Name</label>
</div>
<div class="five wide field">
<input type="text" id="name" placeholder="Your good name goes here..">
</div>
</div>
<div class="inline fields">
<div class="three wide field required">
<label>Place</label>
</div>
<div style="width: 290px;">
<input type="text" placeholder="Where are you from ?">
</div>
<button style="margin:1em;" class="ui primary button" id="btn_validate">Validate</button>
</div>
</form>
<script type="text/javascript">
$("#btn_validate").click(function(){
alert("you clicked me");
// Why page reloading here ?...
});
</script>
</body>
</html>单击Validate按钮后,页面将在显示警报消息后重新加载。
我在哪里搞错了?
发布于 2017-03-26 15:30:23
https://stackoverflow.com/questions/43030442
复制相似问题