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

master
LiaoYijun 1 year ago
parent 167ef36e1c
commit bb8e312c2f

@ -70,7 +70,7 @@
</div>
<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>
@ -454,4 +454,21 @@
});
})(document);
</script>
</script>
<script src="https://data.chinahighlights.com/js/min.php?f=/js/jquery-1.8.2.min.js,/js/jquery.mailAutoComplete-4.0.min.js&amp;v=20231110"></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>
Loading…
Cancel
Save