【发布时间】:2021-08-04 14:02:26
【问题描述】:
我正在尝试生成电话输入字段,我已经成功了。
要求1:需要在下拉列表中显示国家标志和国家名称 要求 2:一旦选择了国家,它将在下一个文本文件中显示国家代码。
输出会是这样的:
$("#mobile-number").intlTelInput({
initialCountry: "auto",
geoIpLookup: function(callback) {
$.get('https://ipinfo.io', function() {}, "jsonp").always(function(resp) {
var countryCode = (resp && resp.country) ? resp.country : "";
callback(countryCode);
});
},
utilsScript: "https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/11.0.9/js/utils.js" // just for formatting/placeholders etc
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://www.jquery-az.com/jquery/js/intlTelInput/intlTelInput.js"></script>
<link href="https://www.jquery-az.com/jquery/css/intlTelInput/demo.css" rel="stylesheet" />
<link href="https://www.jquery-az.com/jquery/css/intlTelInput/intlTelInput.css" rel="stylesheet" />
<h1>A demo with IP lookup</h1>
<form style="margin-left:150px;">
<input type="tel" id="mobile-number" placeholder="e.g. +1 702 123 4567">
</form>
【问题讨论】:
-
我在这里没有看到问题。您是否正在寻求将国家代码输入文本字段的帮助?
-
是的,国家名称以国旗显示为标签
标签: javascript html css