根据用户选择的城市,显示这个城市的天气信息。api接口:http://wthrcdn.etouch.cn/weather_mini?city=深圳 注意:这个接口已经服务端打破了同源。
效果:
Paste_Image.png
html :
p {
width: 100px;
height: 200px;
background: cadetblue;
float: left;
margin-right: 20px;
}
请选择你所在的城市:
北京
上海
广州
深圳
珠海
厦门
杭州
未来五天的天气
var sel = document.querySelector("select");
var div = document.querySelector("div");
sel.onchange = function(){
var city = sel.value;
div.innerHTML = "";
ajax.get({
url: "http://wthrcdn.etouch.cn/weather_mini?city=" + encodeURIComponent(city),
onSucces