Dropdown Results for Website Search

泪湿孤枕 提交于 2020-01-06 07:57:52

问题


I am wondering if there is a service or solution to creating a website search that will allow me to have the results populate into a dropdown window below my search bar, rather than have to populate the results to a new page. Kind of like google's word prediction/suggestion, but rather than on-the-fly suggestions, I would like a new DIV to drop down with the results upon submission.

The website I am working on is at: http://www.conceptsuppliers.com/beta


回答1:


I highly recommend using the jQuery Tokeninput plugin. I recently implemented this on a site for live searching functionality and it works perfectly.

The library provides options for styling every aspect of the search bar and dropdown results list.

Example:

<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript" src="jquery.tokeninput.js"></script>
<link rel="stylesheet" type="text/css" href="token-input.css" />

<script type="text/javascript">
$(document).ready(function () {
    $("#searchbar").tokenInput("/url_to_your_search_endpoint");
});
</script>

The plugin can be found, along with documentation, here: http://loopj.com/jquery-tokeninput/



来源:https://stackoverflow.com/questions/10341165/dropdown-results-for-website-search

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!