我尝试在按enter键时搜索,这里我使用livesearch.js进行搜索,但是这个js在输入时总是搜索。我要它在按回车时搜索。因此,iI尝试了改变,但仍然不起作用。
框架js
<script type="text/javascript" src="framework/liveSearch/livesearch.js"></script><input type="text" id="livesearch" class="livesearch" style="margin-top:0;"/>
<div class="searchresult" id="liveRequestResults"></div>
<iframe id="mainResult" src='log-list.php'></iframe>Javascript
<script>
$('#livesearch').keydown(function(e) {
if(e.keyCode == 13) // I tried this code, first enter worked, after that back to search when typing
{
liveReqInit('livesearch','liveRequestResults','log-ls.php','','mainResult'); //this search work when typing
}
})
</script>发布于 2018-02-07 04:19:11
据我所知,你想要一个普通的搜索框。它将把值提交到后端(我假设它是log-ls.php)。
<form action="log-ls.php">
<input type="search" placeholder="Search..." name="search">
<button type="submit" value="Submit">Submit</button>
</form>
https://stackoverflow.com/questions/48655382
复制相似问题