我正在使用带有simpleweather插件的jquery。 (我正在使用HTML5和Cordova编写应用程序)
我有一个背景图片,我想用温度覆盖
-HTML-HEAD -
$(document).ready(function() {
$.simpleWeather({
location: '',
woeid: '12474497',
unit: 'c',
success: function(weather) {
html = '<p>'+weather.temp+'°'+weather.units.temp+'</p>';
$("#weather").html(html);
},
error: function(error) {
$("#weather").html('<p>'+error+'</p>');
}
});
});
-HTML -
<div id="third" class="top_navi">
<div id="weather">
<a href="#" onclick="window.open('http://mobile.wetter.com/', '_blank', 'location=no')"></a>
</div>
</div>
-CSS -
#third{
background:url(../img/start/btnweather.jpg);
width: 95px;
height: 45px;
}
#third a{
width: 100%;
height: 100%;
display: block;
}
不包括温度我的链接工作正常,我可以点击图像和 - &gt;我的浏览器打开链接。如果我现在放入#weather ...链接不再起作用,我得到温度“13°C”。如何在我的图像上添加链接并显示温度?
答案 0 :(得分:0)
你的功能是将温度插入你的锚标签所在的#weather的html中。只需将#weather div放在锚标记内
<a href='#' onclick='do stuff'>
<div id='weather'>
//this is where your temp will go
</div>
</a>
更新:单独进行临时和链接
<div id='weather'>
<div id='temp'>
//this is where your temp will go
</div>
<a href='#' onclick='do stuff'>
</a>
</div>