我使用jQuery和引導來給下拉搜索suggestions.Following是html代碼。但當我在搜索窗體中鍵入的東西,然後清除窗體。兩個窗體apears如圖片。爲什麼?我是jQuery的新手。謝謝你的幫助。爲什麼會出現兩種形式?
<div class="container">
<div class="row">
<div class="span6 offset3">
<form class="form-search">
<input type="text" id="month" name="month" class="input-medium search-query">
<button type="submit" class="btn">Search</button>
<div id="suggestions">
</div>
</form>
</div>
</div>
</div>
<script>
jQuery("#month").keyup(function(){
ajax('search', ['month'], 'suggestions')});
</script>
編輯: 我使用的web2py framwork.This是搜索功能的代碼:
def search():
if not request.vars.month: return dict()
month_start = request.vars.month
selected=complete('piracyfinder',month_start) #this line get the search results
return DIV(*[DIV(k['title'],
_onclick="jQuery('#month').val('%s')" % k['title'],
_onmouseover="this.style.backgroundColor='lightblue'",
_onmouseout="this.style.backgroundColor='white'"
) for k in selected])
ajax()函數是什麼? – kennypu 2013-03-19 02:09:46