jquery Automatic completion feature plug-in Flexselect usage example _jquery

Source: Internet
Author: User

This example describes the jquery automatic completion function plug-in flexselect usage. Share to everyone for your reference, specific as follows:

I'm doing a thing these days. Need to use automatic completion of the function. That is, the text item of the Select control lets it write. The default Select text box is read-only and cannot be written. Find a jquery plugin on the Web: Flexselect can complete this feature.

Put the plugin in the project. Then refer to the plugin in the page.

<script src= "${pagecontext.request.contextpath}/js/jquery.flexselect-0.2/jquery.flexselect.js"  type= " Text/javascript "></script>
<script src=" ${pagecontext.request.contextpath}/js/ Jquery.flexselect-0.2/liquidmetal.js "  type=" Text/javascript "></script>
<link href=" ${ Pagecontext.request.contextpath}/js/jquery.flexselect-0.2/flexselect.css "rel=" stylesheet "type=" Text/css ">

Then write the code in the JS script:

<script type= "Text/javascript" >
jQuery (document). Ready (function () {
 $ ("Select[class*=flexselect]") . Flexselect ();
});
</script>

At first it was written:

<script type= "Text/javascript" >
var jq = jquery.noconflict ();
JQ (function () {
 JQ ("Select[class*=flexselect]"). Flexselect ();
 JQ ("#province"). Change (function () {
 JQ ("#city"). empty ();
 if ($ ("#province"). Val ()!= "") {
  ajaxpost ("${pagecontext.request.contextpath}/test/querycitybyprovince.do"), backcity,{"province": JQ ("#province"). Val ()});}};


But in this case, with one of the other JS conflict. We don't know what's going on yet.

In addition, if the select is dynamically generated through JS. Then add the following sentence in the corresponding position:$ ("Select[class*=flexselect]"). Flexselect ();

function Backquery (data) {
 var result=data[0][' resultlist '];
 var html= "";
 html+= "<td width= ' 25% ' >serial group <font color= ' Red ' >*</font>:</td>";
html+= "<script type= ' text/javascript ' >$ (\" Select[class*=flexselect]\ "). Flexselect () \;<\/script>"; Note: If you do not add this sentence, it will not effect ~ ~
html+= "<td width= ' 75% ' ><select name= ' serialteamname ' ' class= ' flexselect ' width:200px ' > ';
for (Var i=0;i<result.length;i++) {
 html+= "<option value=" +result[i][' name ']+ ' > "+result[i][' Name ']+" </option> ";
}
html+= "</select></td>";
$ ("#serialGroupTr"). Append (HTML);

More interested readers of jquery-related content can view the site topics: "jquery Extended Tips," "jquery common Plug-ins and Usage summary", "jquery drag-and-drop effects and tips summary", "jquery table (table) Operation Tips Summary", " A summary of Ajax usage in jquery, a summary of common classic effects in jquery, a summary of jquery animation and special effects usage, and a summary of jquery selector usage

I hope this article will help you with the jquery program design.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.