Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialLindsay Grizzard
6,403 PointsweatherReport.main.temp
I have been stuck on this for far too long. There was another post about the answer but I still didn't understand it. If anyone could help that would be so great.
$(document).ready(function() {
var weatherAPI = 'http://api.openweathermap.org/data/2.5/weather';
var data = {
q : "Portland,OR",
units : "metric"
};
function showWeather(weatherReport) {
$('#main').text('#temperature')
$("weatherReport.main.temp");
};
});
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>What's the Weather Like?</title>
<script src="jquery.js"></script>
<script src="weather.js"></script>
</head>
<body>
<div id="main">
<h1>Current temperature: <span id="temperature"></span>°</h1>
</div>
</body>
</html>
2 Answers
Marcus Parsons
15,719 PointsHey Lindsay Grizzard,
I see what you're doing there. But, let me explain why that code isn't quite correct.
You did the first part of the task, but the 2nd part of the task asks to you select the element with the id of temperature. So your $("#main")
selector should be: $("#temperature")
. Once you get to the third part of the task, it wants you to set the element with the ID of temperature to the text contained in the weatherReport object which is of course weatherReport.main.temp
. That means you have to call the text
function on that $("#temperature")
selector like so:
function showWeather(weatherReport) {
$("#temperature").text(weatherReport.main.temp);
}
That will set the text
of #temperature to the temp gained from the weatherReport object! :)
george NGOWI
Courses Plus Student 7,499 PointsThis works for me: var showWeather = function(weatherReport){ $('#temperature').addClass('#main');
}
Marion Giraud
7,145 PointsMarion Giraud
7,145 PointsThanks Marcus ! I didn't understand this challenge too until your comment ! I've just get 12 points more thanks to you !
Marcus Parsons
15,719 PointsMarcus Parsons
15,719 PointsYou're welcome, Marion! :)