手机
当前位置:查字典教程网 >编程开发 >Javascript教程 >Jquery获取当前城市的天气信息
Jquery获取当前城市的天气信息
摘要:本文实例为大家分享了Jquery获取当前城市的天气信息代码,供大家参考,具体内容如下HTML代码:Jquery代码:functionfind...

本文实例为大家分享了Jquery获取当前城市的天气信息代码,供大家参考,具体内容如下

HTML代码:

<div id="weather"></div>

Jquery代码:

function findWeather() { var cityUrl = 'http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js'; $.getScript(cityUrl, function(script, textStatus, jqXHR) { var citytq = remote_ip_info.city ;// 获取城市 var url = "http://php.weather.sina.com.cn/iframe/index/w_cl.php" + citytq + "&day=0&dfc=3"; $.ajax({ url : url, dataType : "script", scriptCharset : "gbk", success : function(data) { var _w = window.SWther.w[citytq][0]; var _f= _w.f1+"_0.png"; if(new Date().getHours() > 17){ _f= _w.f2+"_1.png"; } var img = "<img width='16px' height='16px' src='http://i2.sinaimg.cn/dy/main/weather/weatherplugin/wthIco/20_20/" +_f + "' />"; var tq = citytq + " " + img + " " + _w.s1 + " " + _w.t1 + "℃~" + _w.t2 + "℃ " + _w.d1 + _w.p1 + "级"; $('#weather').html(tq); } }); }); } findWeather();

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持查字典教程网。

【Jquery获取当前城市的天气信息】相关文章:

Jquery中基本选择器用法实例详解

JS或jQuery获取ASP.NET服务器控件ID的方法

JavaScript实现弹出模态窗体并接受传值的方法

JQuery插件jcarousellite的参数中文说明

jQuery获取上传文件的名称的正则表达式

JQuery+CSS实现图片上放置按钮的方法

JavaScript获取两个数组交集的方法

Jquery实现动态切换图片的方法

jquery简单实现外部链接用新窗口打开的方法

jQuery实现延迟跳转的方法

精品推荐
分类导航