JQuery 组合框和 JSP
我正在尝试使用 JQuery 中的这个插件,但是如何填充选择的选项组合框?我对 JQuery 还很陌生,所以希望能得到一些帮助
所以假设我有一个 html 代码,如下所示:
<select name = "test">
<option>1</option>
<option>2</option>
</select>
我应该做什么才能使其具有上面的界面?
I am trying to use this plugin from JQuery, however how do I populate the options of the selection of the combo box? I am pretty new to JQuery so some help would be appreciated
So say I have a html code as follows:
<select name = "test">
<option>1</option>
<option>2</option>
</select>
what should I do to make it so I have the interface above?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
查看此页面上的示例。
您仍然创建一个带有子选项的 html select 元素。然后你可以用一个非常简单的 $('#comboboxy').combobox() 将它变成一个 jquery 组合框。如果您愿意,我可以帮助您提供更高级的选项。
Checkout the example on this page.
You still create an html select element with child options. Then you turn it into a jquery combobox with either a really simple $('#comboboxid').combobox(). If you want, I can help you with the more advanced options.
这个 jQuery 插件仅通过可自定义的 CSS 样式增强 HTML
顺便说一句,这个插件已经很老了,而且它的名字也很容易让人误解。组合框本质上是一个可编辑的下拉列表。但这个插件根本不做任何事情。您实际上的功能需求是什么?你是不是看错插件了?
更新:至于如何使用,只需包含必填
中的 JS 文件并在文档加载期间调用
$(selector).combobox()
。甚至还有一个完整的示例此处(请注意,您需要单击“单击以查看/隐藏”链接以查看 HTML)。This jQuery plugin only enhances the look'n'feel of a HTML
<select>
element with customizeable CSS styles. It doesn't require any changes to standard HTML/JSP/whatever code you're using to populate the options. You can just write down the dropdown options the usual way in JSP as you would do without this jQuery plugin.By the way, that plugin is pretty old and its name is fairly misleading. A combobox is in essence an editable dropdown. But this plugin does nothing about that at all. What's actually your functional requirement? Aren't you looking at the wrong plugin?
Update: as to how to use it, just include the required JS files in
<head>
and call$(selector).combobox()
during document load. There's even a complete example here (note that you need to click the "click to view/hide" link to see the HTML).