Source code here---
https://ide.geeksforgeeks.org/tryit.php/8yf8BwXlsD
Js code just Copy and past in your js file and in HTML
the file you need to create a select tag something like this ----
<select id='demo'>
<option>Select Your Coountry</option>
</select>
<style>
#demo{
font-size: 19px;
border: 5px solid green;
height: 57px;
}
</style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<script>
$(document).ready(function(){
$.get("https://raw.githubusercontent.com/sknetking/xmlcdn/main/country_list.json", function(data, status){
let obj = JSON.parse(data);
for (let i = 0; i < obj.length; i++) {
$("#demo").append("<option value='"+obj[i].code+"'>"+obj[i].name+"</option>");
}
});
$("#demo").change(function(){
alert($("#demo").val());
});
});
</script>
<select id='demo'>
<option>Select Your Coountry</option>
</select>
If you like this code or this code is helpful for you than please share and leave comment here . Thank you 🙏.
0 Comments