-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
23 lines (16 loc) · 952 Bytes
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
const apiKey = 'c5a9687e31c94d5db0771544230307';
const apiUrl = 'http://api.weatherapi.com/v1/current.json?&q=';
const searchInput =document.querySelector('.search input');
const searchBtn = document.querySelector('.search button');
async function weatherData(city) {
const response = await fetch(apiUrl+ city + '&key=' + apiKey);
const data = await response.json();
document.querySelector('.weather').style.display='block';
document.querySelector('.city').innerHTML= data.location.name;
document.querySelector('.text').innerHTML= data.current.condition.text;
document.querySelector('.humidity').innerHTML= data.current.humidity + '%';
document.querySelector('.wind').innerHTML= data.current.wind_kph + 'km/h';
document.querySelector('.temp').innerHTML= data.current.temp_c + '°c' ;
document.getElementById('icon').src=data.current.condition.icon;
}
document.getElementById("year").innerHTML= new Date().getFullYear();;