如何获得autosuggest插件的价值 [英] how to get value of autosuggest plugin

查看:143
本文介绍了如何获得autosuggest插件的价值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用此 http://code.drewwilson.com/entry/autosuggest- jQuery插件

这是我的html

   <h1>Category : </h1>
    &nbsp;<input type="text" name="category" id="category" size="4"/> 
    &nbsp;<input type="button" name="category" id="gocategory"  value="Go"/>

这是我的jquery代码:

here is my jquery code :

$(document).ready(function() {
  // put all your jQuery goodness in here.
    var data = {items: [
        {value: "21", name: "Mick Jagger"},
        {value: "43", name: "Johnny Storm"},
        {value: "46", name: "Richard Hatch"},
        {value: "54", name: "Kelly Slater"},
        {value: "55", name: "Rudy Hamilton"},
        {value: "79", name: "Michael Jordan"}
    ]};
    $("#category").autoSuggest(data.items, {selectedItemProp: "name", searchObjProps: "name"});
    // $("#category").autoSuggest("http://mysite.com/path/to/script", {minChars: 2, matchCase: true});;
    $("#gocategory").click(function(){
        alert($("#category").value);
    });
});

我如何在onclick事件中获取所选类别的值?

How i will get the value of the selected category in the onclick event ?

推荐答案

在每次执行选择时都会发生onsubmit事件或类似tis的事件,因此可以获取值.

There is an event onsubmit or something like tis on each selection that function is executed .so by that way we can get the value.

这篇关于如何获得autosuggest插件的价值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆