如何在引导国家/地区选择器中 select 所需的国家/地区?

how to select desired country in bootsratp country picker?

下面的代码显示了美国国旗,并且在加载下拉列表时选择了美国。

<div class="bfh-selectbox bfh-countries" data-country="US" data-flags="true"></div>

我想以一种形式选择英国,以另一种形式选择伊拉克,但在下面尝试时它不显示国家国旗和国家名称。

<div class="bfh-selectbox bfh-countries" data-country="UK" data-flags="true"></div>
<div class="bfh-selectbox bfh-countries" data-country="IRQ" data-flags="true"></div>

以上选择的代码默认为空

我怎样才能将英国和伊拉克国旗显示为如何在 <div class="bfh-selectbox bfh-countries" data-country="US" data-flags="true"></div>

上选择美国名称和国旗

我自己找到了答案:

  • 对于英国,使用 data-country="GB"
  • 对于伊拉克,使用 data-country="IQ"

要使其正常工作,您应该添加指向 CSS 的链接和 Bootstrap Form Helpers 库的 JS 文件,这些文件应该事先下载到您的服务器上

 <link href="css/bootstrap-form-helpers.min.css" rel="stylesheet">
    <script src="js/bootstrap-formhelpers.min.js"></script>

<div class="bfh-selectbox bfh-countries" data-country="US" data-flags="true">
</div>

根据国家代码显示国家名称和国旗的示例

<span class="bfh-countries" data-country="US" data-flags="true"></span>

阅读更多相关信息 http://www.freenetmall.com/common/jquery/FormHelpers/docs/country.html