我想獲得一個搜索框,當我點擊搜索圖標顯示,目前的問題是,當它出現它也提交搜索。我怎樣才能讓搜索框出現,但不提交搜索,這隻有當在搜索框中輸入內容並點擊提交時纔會顯示。目前的搜索輸入框與jquery點擊,但不提交
https://jsfiddle.net/9twxq1Lq/1/
<form class="search" method="post" action="/search">
<input type="text" name="criteria" placeholder="Search Box">
<button>
<i class="icons icon-search" aria-hidden="true"></i> <span class="sr">Search Box</span>
</button>
</form>
給予返回false,您想在其中限制提交表單 – rahulsm
在您的javascript按鈕onclick中添加event.preventDefault();這可以防止按鈕執行其默認行爲 –