【发布时间】:2023-03-30 19:01:01
【问题描述】:
我有这个 html 代码
<div class="weather">
<div id="weather"></div>
</div>
我正在使用此代码隐藏天气,然后以淡入淡出效果显示,但淡入淡出不起作用,那么我怎样才能使天气 div 以淡入淡出效果显示?
$("#weather").weatherfeed(['SAXX0017']);
$("select[name='weather']").change(function(){
var city = $(this).val()
//alert(city);
$(".weather").fadeOut(500,function(){
$(this).children("#weather").empty();
$("#weather").weatherfeed([city]);
$(".weather").fadeIn(500);
});
});
【问题讨论】:
-
在调用 .weatherfeed 后需要查看 html
-
什么是
weatherfeed()?当然,淡入淡出必须在完成之后进行,将其放在下一行可能还不够。如果它是异步调用,那么它可能需要比淡入淡出更长的时间,这就是它似乎不起作用的原因。 -
这是一个连接网站获取所选代码天气的函数
-
忽略我的回答,阅读不好。
.weatherfeed()是做什么的?确保它正确返回 -
请记住,
.weatherfeed()必须立即用 HTML 重新填充元素。.fadeIn()和.fadeOut()不喜欢空元素,而在它之前有一个.empty()调用。