0
我試圖將自動填充搜索框中的選定值添加到我的id =「merkenlijst」。問題是,當品牌被添加時,它只會閃爍一秒,然後消失。我找不到我做錯了什麼。爲什麼我的表單輸入值不添加新數據?
<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
<script>
$(document).ready(function() {
$("input#autocomplete").autocomplete({
source: ["Adidas", "Airforce", "Alpha Industries", "Asics", "Bikkemberg", "Birkenstock", "Bjorn Borg", "Brunotti", "Calvin Klein", "Cars Jeans", "Chanel","Chasin", "Diesel", "Dior", "DKNY", "Dolce & Gabbana"]
});
$("#add-brand").click(function(){
var merk = $("#autocomplete").val();
$("#merkenlijst").append(merk);
});
});
</script>
<style type="text/css">
body{ margin: 0 auto; width: 540px; }
</style>
<title>Form add brands </title>
</head>
<body>
<div id="brands-form-holder">
<form id="brands-form" action="" method="">
<dl>
<dt>
<h1>
<label for="brands-form-brand">Add your brands</label>
</h1>
</dt>
<dd>
Search for brand:
<input id="autocomplete" type="text" name="brand" />
<input id="add-brand" type="submit" value="Add brands" />
</dd>
</dl>
</form>
<hr />
<p class="section-title">
<strong>Brands selected</strong> (including from the database)
</p>
<div id="merkenlijst"> </div>
</div>