Sr.no | Country | Date | NewConfirmed | NewDeaths | NewRecovered | TotalConfirmed | TotalDeaths | TotalRecovered |
---|
Sample code:-
<!DOCTYPE html>
<html>
<head>
<title>Corona Virus Update Global And County Wise</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
</head>
<body>
<style>
* {
box-sizing: border-box;
}
#myInput {
background-image: url('/css/searchicon.png');
background-position: 10px 10px;
background-repeat: no-repeat;
width: 100%;
font-size: 16px;
padding: 12px 20px 12px 40px;
border: 1px solid #ddd;
margin-bottom: 12px;
}
#myTable {
border-collapse: collapse;
width: 100%;
border: 1px solid #ddd;
font-size: 18px;
}
#myTable th, #myTable td {
text-align: left;
padding: 12px;
}
#myTable tr {
border-bottom: 1px solid #ddd;
}
#myTable tr.header, #myTable tr:hover {
background-color: #f1f1f1;
}
</style>
</head>
<body>
<input type="text" id="myInput" onkeyup="myFunction()" placeholder="Search for names.." title="Type in a name">
<table class="table table-strpped" id="myTable">
</table>
<br>
<table class="table table-bordered table-striped" id="Countrywise" style="border: 1px solid black;">
<tr >
<th>Sr.no</th>
<th>Country</th>
<th>Date</th>
<th>NewConfirmed</th>
<th>NewDeaths</th>
<th>NewRecovered</th>
<th>TotalConfirmed</th>
<th>TotalDeaths</th>
<th>TotalRecovered</th>
</tr>
</table>
<script>
function myFunction() {
var input, filter, table, tr, td, i, txtValue;
input = document.getElementById("myInput");
filter = input.value.toUpperCase();
table = document.getElementById("myTable");
tr = table.getElementsByTagName("tr");
for (i = 0; i < tr.length; i++) {
td = tr[i].getElementsByTagName("td")[0];
if (td) {
txtValue = td.textContent || td.innerText;
if (txtValue.toUpperCase().indexOf(filter) > -1) {
tr[i].style.display = "";
} else {
tr[i].style.display = "none";
}
}
}
}
</script>
</body>
</html>
<script src="https://code.jquery.com/jquery-3.6.0.js" integrity="sha256-H+K7U5CnXl1h5ywQfKtSj8PCmoN9aaq30gDh27Xc0jk=" crossorigin="anonymous"></script>
<script type="text/javascript">
$.ajax({
url:"https://api.covid19api.com/summary",
type:"GET",
dataType:"JSON",
success:function(data){
console.log(data.Countries);
$.each(data.Global,function(key,value){
$("#myTable").append("<tr><td>"+ key+ "</td><td>"+ value+ "</td></tr>");
});
var srno = 1;
$.each(data.Countries,function(key,value){
$("#Countrywise").append("<tr>"+
"<td>"+ srno+ "</td>"+
"<td>"+ value.Country+ "</td>"+
"<td>"+ value.Date+ "</td>"+
"<td>"+ value.NewConfirmed+ "</td>"+
"<td>"+ value.NewDeaths+ "</td>"+
"<td>"+ value.NewRecovered+ "</td>"+
"<td>"+ value.TotalConfirmed+ "</td>"+
"<td>"+ value.TotalDeaths+ "</td>"+
"<td>"+ value.TotalRecovered+ "</td>"+
"</tr>");
srno++;
});
}
});
</script>
Thanks you for commenting your questions. I will see question and respond you.