0
我有一個文本輸入是製作和AJAX數據庫調用和填充一個基於搜索的鏈接集相鄰的div。當用戶離開輸入和div時,我想隱藏div。我不知道如何將一個函數放在一起檢查兩個條件。如何設置基於兩個條件的jQuery動作
這是HTML部分。
<form name="searchform" id="sform" action="searchflowers.asp" method="get" style="float:left">
<input type="hidden" name="mode" value="search">
<input type="hidden" name="pf" value="Y">
<input type="hidden" name="itype" value="flower">
<input type="search" name="srch" id="thisbox" maxlength="30" id="srch" placeholder="search flowers"
autocomplete="off">
<input type="submit" value="Go" class="tinybutton">
<div id="suggestions"></div>
和腳本。
//jquery functions
$(document).ready(function(){
//initially hide suggestions box
$("#suggestions").hide()
//retrieve matching results
$("#thisbox").keyup(function() {
$("#suggestions").show()
$("#suggestions").load("scripts/getlist.asp?letters=" + $("#thisbox").val())
});
//********** this is the piece I need to fix *************
$("#sform").mouseout(function() {
$("#suggestions").hide("slow")
});
});
Umm ...當用戶離開輸入時設置一個變量。當你離開div時檢查變量嗎? –
當你說「用戶離開文本框」時,你的意思是他們什麼時候忽略它? – tt9
請請 - 學習如何使用** angularjs **或**反應**而不是使用jQuery - 它會讓你的生活更輕鬆 – ymz