我正在尝试制作一个PHP Ajax实时搜索框,到目前为止工作正常,但似乎我面临两个问题:
这里是代码:
<div class="widget-container widget_search">
<span class="adds"></span>
<form action="" id="searchform" method="POST">
<p>
<input type="text" id="search" placeholder="Chercher" size="30" name="search">
<button type="submit" id="searchsubmit"></button>
</p>
</form><!--/ #searchform-->
<div id="livesearch" style=" width:auto; height:auto; margin:auto; position: absolute;"></div>
</div><!--/ .widget-container-->
JS:
$(document).ready(function(){
$("#search").keyup(function(){
var valor = $("#search").val();
$.ajax({
type: "POST",
url: "/auto/search/",
data: {word:valor},
success: function(res) {
$('#livesearch').html(res);
}
});
});
});
答案 0 :(得分:0)
使用jquery: div的livesearch-id(搜索框) div的one-id,显示搜索元素 $(&#34;#livesearch&#34;)。mouseout(function(){$(&#39;#one&#39;)。hide(); //隐藏div }); $(&#34;#livesearch&#34;)。mouseover(function(){$(&#39;#one&#39;)。show(); //再次指向鼠标时显示div });
CSS: set style =&#34; margin-left :( number)px;&#34;