我目前正在制作一个包含通知的网站,但我不太确定如何在按钮上显示它们。诸如“显示天气”之类的内容将在底部角落的某处显示通知。使用Ajax/Javascript按钮按下按钮时弹出通知?
http://i.stack.imgur.com/v8pEd.png
是何等的难将能够做什么?它实际上可能吗?
我目前正在制作一个包含通知的网站,但我不太确定如何在按钮上显示它们。诸如“显示天气”之类的内容将在底部角落的某处显示通知。使用Ajax/Javascript按钮按下按钮时弹出通知?
http://i.stack.imgur.com/v8pEd.png
是何等的难将能够做什么?它实际上可能吗?
可以显示。
使用click()
作为按钮按下事件。
$("button_reference").click(function(){
// do your notification-related stuff here
});
您可以使用Click事件显示弹出,如果你需要在一些动画的方式通知,你可以使用jQuery动画
这里是展现天气为例点击一个按钮。使用这种堵塞--- 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+'°'+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();
});
DEMO
这里是使用Jquery UI弹出的Demo。
所以,你需要点击功能,如果有什么具体的像天气的worh使用堵漏。
你可以在.click()
函数的帮助下显示它,这是jQuery中的一个内置函数。
$("the_id").click(function(){
//your stuff here
});
查找更多信息有关.click()
here。
首先尝试找到一个解决方案,你自己。然后放下你尝试过的一些代码。之后,我们都会帮助你解决它。 :D – yeshansachithak
thw问题不清楚,你希望你的通知如何显示? – Sweetz