如何在自动完成中获取所选项目的值 [英] how to get value of selected item in autocomplete
本文介绍了如何在自动完成中获取所选项目的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我这里有一个来自 http://jqueryui.com/autocomplete/ 的代码,它确实很好用,但是我找不到在文本视图中获取所选项目值的方法我尝试过类似的操作,但它不起作用
<!doctype html><html lang="zh-cn"><头><meta charset="utf-8"/><title>jQuery UI 自动完成 - 默认功能</title><link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css"/><script src="http://code.jquery.com/jquery-1.9.1.js"></script><script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script><link rel="stylesheet" href="/resources/demos/style.css"/><脚本>$(函数(){var availableTags = ["动作脚本","AppleScript","阿普",基本的",C","C++","Clojure","COBOL","冷聚变","二郎","Fortran",格调","哈斯克尔","爪哇","JavaScript","Lisp","珀尔","PHP",Python",红宝石","斯卡拉",方案"];$( "#tags" ).autocomplete({来源:availableTags});});<脚本>$(document).ready(function () {$('#tags').change(function () {$('#tagsname').html('你选择了:' + this.value);}).改变();});头部><身体><div class="ui-widget"><label for="tags">标签:</label><input id="tags"/><div id="标签名"></div>