Home >Web Front-end >JS Tutorial >JavaScript code implements the fuzzy prompt function of the input input box

JavaScript code implements the fuzzy prompt function of the input input box

小云云
小云云Original
2018-02-01 13:10:462207browse

This article mainly introduces to you the relevant information about the implementation of the fuzzy prompt function of the javascript input input box. I hope it can help you through instinct. Friends in need can refer to it. I hope it can help everyone.

Realization of the fuzzy prompt function of the javascript input input box

Mainly uses the jQuery.autocomplete function. You can use this function after defining an array. It is very convenient.


<!doctype html>
<html>
<head>
 <meta charset="utf-8">
 <link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css" rel="external nofollow" >
 <script src="//code.jquery.com/jquery-1.10.2.js"></script>
 <script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
 <script>
 $(function() {
  var availableTags = [
   "James",
   "Kobe",
   "Jordan"
  ];
  $( "#tags" ).autocomplete({
   source: availableTags
  });
 });
 </script>
</head>
<body>

<p class="ui-widget">
 <label for="tags">Tags: </label>
 <input id="tags">
</p>

</body>

Effect:

Related recommendations:

input tag Input box with prompt text method

Vue implements an example tutorial of splitting mobile phone numbers in a numeric input box

JS clicks the drop-down menu to synchronize the selected content Go to the input input box to implement the method

The above is the detailed content of JavaScript code implements the fuzzy prompt function of the input input box. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn