我試圖在用戶按下搜索欄中的任意鍵時顯示一條消息。經過多次嘗試,我無法做到。請幫忙。由於在按鍵時顯示提示
<form method="get" >
<input type="submit" value="Search" class="btn" >
<input name="q" type="text" id="search" size="32" maxlength="128" class="txt" >
</form>
以下是我的javascript:
$("#search").keyup(function() { // function starts when a key is entered in the search bar
window.alert("Handler for .keyup() called.");
});
謝謝你。像魅力一樣工作。 – 2013-02-28 07:59:54