Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7997107
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T14:53:26+00:00 2026-06-04T14:53:26+00:00

I am getting some API information from Weather Underground and was wondering if it

  • 0

I am getting some API information from Weather Underground and was wondering if it is possible to change the background color of the entire body through jQuery by using the information provided by the API.

What I would like to do is set a class on the body tag based on a certain range of Temperature that is returned via the API. So for example:

"current_observation": {
    "image": {
    "url":"http://icons-ak.wxug.com/graphics/wu2/logo_130x80.png",
    "title":"Weather Underground",
    "link":"http://www.wunderground.com"
    },
    "display_location": {
    "full":"Bowling Green, KY",
    "city":"Bowling Green",
    "state":"KY",
    "state_name":"Kentucky",
    "country":"US",
    "country_iso3166":"US",
    "zip":"42101",
    "latitude":"37.02899933",
    "longitude":"-86.46366119",
    "elevation":"154.00000000"
    },
    "observation_location": {
    "full":"Ridgeview Drive, Bowling Green, Kentucky",
    "city":"Ridgeview Drive, Bowling Green",
    "state":"Kentucky",
    "country":"US",
    "country_iso3166":"US",
    "latitude":"36.993744",
    "longitude":"-86.522827",
    "elevation":"714 ft"
    },
    "estimated": {
    },
    "station_id":"KKYBOWLI7",
    "observation_time":"Last Updated on May 24, 2:25 PM CDT",
    "observation_time_rfc822":"Thu, 24 May 2012 14:25:18 -0500",
    "observation_epoch":"1337887518",
    "local_time_rfc822":"Thu, 24 May 2012 14:25:29 -0500",
    "local_epoch":"1337887529",
    "local_tz_short":"CDT",
    "local_tz_long":"America/Chicago",
    "local_tz_offset":"-0500",
    "weather":"Clear",
    "temperature_string":"86.8 F (30.4 C)",
    "temp_f":86.8

That is some info I am pulling in. The very last one temp_f is what I want to focus on.

An example of ranges is – 80 through 90 should display background:#dd7f35

I’ve attempted to set up custom variables for this but always wind up breaking things. I can’t seem to figure out how to set up a variable using the information pulled in from the JSON (if that’s even possible since temp_f uses decimals.)

Here is how I am calling the JSON

$().ready(function(){ 
    $.getJSON("http://api.wunderground.com/api/[MY API KEY]/conditions/q/autoip.json?callback=?",
    function(data){
        $.each(data, function(i, json) {
        content = '<h1>' + json.icon + '</h1>';
        content += '<img src=' + json.icon_url +'>';
        content += '<p>' + json.temp_f + '<p>';
        $(content).appendTo("#area");
        });
    console.log(data)
    });
});

Here is something I have tried

var backDrop = ' + json.temp_f + '

I used + json.temp_f +because that is pulling in the temp just fine for the regular HTML but I can kind of assume that’s not going to work in this case?

Any help is greatly appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T14:53:30+00:00Added an answer on June 4, 2026 at 2:53 pm
     var backDrop = json.temp_f;
    

    Just get rid of the quotes and the pluses.

    Or you could do something like this:

     var colorOutput = '';
    
     if(json.temp_f < 20){
         colorOutput = 'blue'; //use hex color
     }else if(json.temp_f >=20 && json.temp_f < 60){
         colorOutput = 'orange'; //use hex color
     }
    
     $('#colorMeElement').css('background',colorOutput);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to parse out some information from Google's geocoding API but I
I am trying to get some information about YouTube channel's from the YouTube API.
Can anyone please share some java codes for getting started with google search api's.I
I'm getting some inexplicable behavior from easymock and a JUnit test case. I'm receiving
I am attempting to get some information from a russian shipping website. Being a
My application fetches information from an API. Unfortunately their data isn't very pretty. This
I'm try to collect some information from the job tracker. For starters I'd like
I need some methods of storing and getting data from a file (in WIN32
I read some info regarding getting .h files for undocumented API. Most of sources
Is there a wrapper around the Win32 API for getting font information without actually

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.