JQuery 语言下拉选择器
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3671917/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
JQuery language drop-down selector
提问by Germstorm
I need an already implemented solution for a JQuery or JavaScript drop-down language selector. The drop-down should open when the user clicks on it and it should display a list of languages with the country's flag on the left.
我需要一个已经实现的 JQuery 或 JavaScript 下拉语言选择器解决方案。当用户点击下拉菜单时,下拉菜单应该会打开,并且应该会在左侧显示带有国家国旗的语言列表。
I cannot even find an example.
我什至找不到一个例子。
采纳答案by Germstorm
I managed to solve this one without JavaScript only by using CSS. Fortunately I found an exampleand copied the functionality.
我仅通过使用 CSS 就设法在没有 JavaScript 的情况下解决了这个问题。幸运的是,我找到了一个示例并复制了该功能。
A simple dropdown was not enough, I needed to display the flags of the languages.
一个简单的下拉菜单是不够的,我需要显示语言的标志。
回答by rfunduk
Won't any jQuery dropdown plugin work just fine? What you're looking for has nothing to do with languages and everything to do with a dropdown. There are tons of thesejust a google away.
任何 jQuery 下拉插件都不能正常工作吗?您要查找的内容与语言无关,而与下拉列表无关。有很多这些只是一个谷歌。
回答by Anri?tte Myburgh
Just implement a regular <select>
box with a .change()
handler on the combo box.
只需在组合框上实现一个<select>
带有.change()
处理程序的常规框。
Are you trying to translate your website on the fly without reloading?
您是否想在不重新加载的情况下即时翻译您的网站?
If yes, then Google has it's very own translation widget that you include in your site, it gives you a combo box with language options (without flags) and translates it inline for you to almost any thinkable language.
如果是,那么 Google 有它自己的翻译小部件,您可以将其包含在您的网站中,它为您提供一个带有语言选项(无标志)的组合框,并将其内联翻译成几乎任何可以想到的语言。