gpt4 book ai didi

javascript - 使用 Ajax/Javascript 按下按钮时的通知弹出窗口?

转载 作者:太空宇宙 更新时间:2023-11-04 03:40:58 24 4
gpt4 key购买 nike

我目前正在制作一个包含通知的网站,但我不太确定如何在按下按钮时显示它们。 “显示天气”之类的内容会在底 Angular 某处显示通知。

http://i.stack.imgur.com/v8pEd.png

它能做到多难?这真的可能吗?

最佳答案

这是一个通过点击按钮来显示天气的例子。使用此堵漏 --- http://simpleweatherjs.com/

HTML

<div id="weather"></div>
<input type="submit" id="Show" value="Current Weather" />

JQUERY

// Docs at http://simpleweatherjs.com
$(document).ready(function() {

$("#weather").hide();

$.simpleWeather({
location: 'Nicosia, CY',
woeid: '',
unit: 'f',
success: function(weather) {
html = '<h2><i class="icon-'+weather.code+'"></i> '+weather.temp+'&deg;'+weather.units.temp+'</h2>';
html += '<ul><li>'+weather.city+', '+weather.region+'</li>';
html += '<li class="currently">'+weather.currently+'</li>';
html += '<li>'+weather.wind.direction+' '+weather.wind.speed+' '+weather.units.speed+'</li></ul>';

$("#weather").html(html);
},
error: function(error) {
$("#weather").html('<p>'+error+'</p>');
}
});
});

$("#Show").click(function(){
$("#weather").show();
});

演示

http://jsfiddle.net/LW3S9/4/

这里是使用 Jquery UI 的弹出窗口的演示。

http://jsfiddle.net/LW3S9/5/

因此,您将需要点击功能,如果某些特定功能(如天气)则需要使用 Plugging。

关于javascript - 使用 Ajax/Javascript 按下按钮时的通知弹出窗口?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24902828/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com