电话区号下拉框添加IP判断

master
LiaoYijun 1 year ago
parent 7d23801b2e
commit ac94a5fc71

@ -183,7 +183,7 @@
<select name="country_code" class="country_code">
<select name="country_code" class="country_code" id="country_code">
<option style="font-weight: 600;" value="United States +1">United States&nbsp; &nbsp;+1</option>
<option style="font-weight: 600;" value="United Kingdom +44">United Kingdom&nbsp; &nbsp;+44</option>
<option style="font-weight: 600;" value="Australia +61">Australia&nbsp; &nbsp;+61</option>
@ -599,6 +599,22 @@
});
})
</script>
<script>
$(function () {
$.getJSON("https://www.chinahighlights.com/guide-use.php/apps/ip2location/index/get_country", function (data) {
var yourCountry = data.country_name;
$('#country_code option').each((i, optionEle) => {
var countryName = optionEle.value.split('+')[0].trim();
if (yourCountry === countryName) {
optionEle.selected = true;
}
});
})
.fail(function (xhr, status, error) {
console.error(error);
});
})
</script>
<style>
.date_select {
width: 27.5% !important;

Loading…
Cancel
Save