我的控制台说明功能weatherData
未定义(Uncaught ReferenceError: weatherData is not defined
)
var days;
$("a").each(function(day){
$(this).on("click", function(){weatherData(day);});
});
function weatherData(day){
weatherDay = this.theWeather.daily.data[day];
show(weatherDay);
}
答案 0 :(得分:0)
$(document).ready(function(){
var days;
$("a").each(function(day){
$(this).on("click", function(){
weatherData(day);
});
});
});
function weatherData(day){
weatherDay = this.theWeather.daily.data[day];
show(weatherDay);
}
答案 1 :(得分:0)
我把它改成了它,现在它可以了!
weatherData = function(day){
weatherDay = this.theWeather.daily.data[day];
show(weatherDay);
}
答案 2 :(得分:0)
<html>
<body>
<a href="" value='1' class='test'> 1 </a>
<a href="" value='2' class='test'> 2 </a>
<script>
$(document).ready(function(){
$('a').click(function(){
var number = $(this).text();
alert(number);
});
});
</script></body>
</html>
很明显你在html文档的顶部有jquery文件和css