Jquery.autocomplete Modify the implementation of the keyboard up and down key automatic fill example _jquery

Source: Internet
Author: User
According to the requirements to achieve through the keyboard move up and down, get the value of the Lenovo menu, as Google Baidu query function.
Looking for a long time on the internet can not find to achieve the function of plug-ins, but only to do their own to change the code.
Find the Key.down and KEY in JS. Up Execution Code
As follows:
Copy Code code as follows:

Case KEY. Down:
Event.preventdefault ();
if (select.visible ()) {
Select.next ();
}
else {
OnChange (0, true);
}
Break

After the Select.next ();
Copy Code code as follows:

var selected = select.selected ();
var v = selected.result;
$input. Val (v);

In this way, the input box will have the corresponding value when the key is added, but the cursor on the keyboard is missing.
Find Select.next (); Definition of code
Copy Code code as follows:

Next:function () {
Moveselect (1);
},

To add a similar method
Copy Code code as follows:

Stay:function () {
Moveselect (1);
},

And then
Copy Code code as follows:

Case KEY. Down:
Event.preventdefault ();
if (select.visible ()) {
Select.next ();
var selected = select.selected ();
var v = selected.result;
$input. Val (v);
Select.stay ();
}
else {
OnChange (0, true);
}
Break

That's it.

================================

Thank the original author very much,

To add a similar method
Copy Code code as follows:

Stay:function () {
Moveselect (1);
When you click the up and down keys, you move the interlace, so instead:

Stay:function () {
Moveselect (0);
},

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.