jquery - Hiding divs using javascript if a certain class is used -


i have website plays css animation of clouds drifting across screen.

i have added javascript function pulls in data yahoo's weather api. i've used change background colour depending on weather. cloud animation have @ moment appears when cloudy (aka when javascript makes body class 'body.cloudy' or 'body.partly-cloudy').

the clouds in divs @ moment, assume need make divs hidden if body other 'body.cloudy' or 'body.partly-cloudy' i'm not sure how this.

<body> <div class="sky">       <div class="cloud cloud01"></div>       <div class="cloud cloud02"></div>       <div class="cloud cloud03"></div>       <div class="cloud cloud04"></div>       <div class="cloud cloud05"></div>       <div class="cloud cloud06"></div>     </div> </body> 

js

$.yql = function(query, callback) {     var encodedquery = encodeuricomponent(query.tolowercase()),         url = 'http://query.yahooapis.com/v1/public/yql?q='             + encodedquery + '&format=json&callback=?';     $.getjson(url, callback); }; $.yql("select * rss url='http://weather.yahooapis.com/forecastrss?p=ukxx0029'",function(data){             var w=data.query.results.item;             var _class=w.condition.text; var encodedclass = _class.replace(/\s+/g, '-').tolowercase();              $('body').addclass(encodedclass);         });    

css

.cloud {   width: 512px;   height: 512px;   position: absolute; }  .cloud01 {   top: 10px;   z-index: 1;   background: url(file://c:/users/sara/documents/explorecanterbury/img/clouds02.png) 0 0 no-repeat;   animation: drift 35s linear infinite; }  .cloud02 {   top: 10px;   z-index: 1;   background: url(file://c:/users/sara/documents/explorecanterbury/img/clouds03.png) 0 0 no-repeat;   animation: drift02 35s linear infinite; }  .cloud03 {   top: 10px;   z-index: 1;   background: url(file://c:/users/sara/documents/explorecanterbury/img/clouds04.png) 0 0 no-repeat;   animation: drift02 55s linear infinite; }  .cloud04 {   top: 10px;   z-index: 1;   background: url(file://c:/users/sara/documents/explorecanterbury/img/clouds04.png) 0 0 no-repeat;   animation: drift 45s linear infinite; }  .cloud05 {   top: 10px;   z-index: 1;   background: url(file://c:/users/sara/documents/explorecanterbury/img/clouds03.png) 0 0 no-repeat;   animation: drift 30s linear infinite; }  .cloud06 {   top: 10px;   z-index: 1;   background: url(file://c:/users/sara/documents/explorecanterbury/img/clouds02.png) 0 0 no-repeat;   animation: drift02 25s linear infinite; }  @keyframes drift {   {transform: translate(-150px,-550px);}   {transform: translate(350px, 550px);} }  @keyframes drift02 {   {transform: translate(350px,-550px);}   {transform: translate(1050px, 550px);} }  body.unknown{   background-color: blue; } body.cloudy, body.partly-cloudy, body.mostly-cloudy {   background-color: red; }  body.rain, body.thunderstorms, body.drizzle, body.showers, body.thundershowers, body.scattered-showers, body.scattered-thunderstorms, body.isolated-thunderstorms {   background-color: blue; }  body.sunny, body.fair, body.hot {   background-color: yellow; }  body.snow, body.mixed-rain-and-snow, body.mixed-rain-and-sleet, body.snow-flurries, body.light-snow-showers, body.blowing-snow, body.hail, body.sleet, body.snow-showers, body.heavy-snow {   background-color: black; } 

i'd think css it:

/* hide clouds default */ body .cloud {     display: none; } /* show them when it's cloudy or partly-cloudy */ body.cloudy .cloud, body.partly-cloudy .cloud {     display: block; } 

Comments

Popular posts from this blog

gridview - Yii2 DataPorivider $totalSum for a column -

java - Suppress Jboss version details from HTTP error response -

Sass watch command compiles .scss files before full sftp upload -