javascript - Using jQuery to rearrange page elements -


I'm relatively new to jQuery and JavaScript, and I think I understand what my problem is, but I Not sure how to fix it.

I have the simple time to get the current time and season for 4 cities. Js, moment I am using JS, and moment.JS timezone. I have all the data on the page, but I want to transfer the time of every city as the second paragraph in every city's development. Any ideas about how to work with my existing code or a more efficient way of producing this result?

This is my JS:

  $ (document) .ready (function () {$ ('. Season'). Function () (Var City = $ (this) .attr ("city"); Viral despair = $ (this) .attr ("woeid"); var degree = $ (this) .attr ("degrees"); var Continent = $ (this) .attr ("continent"); $ .simpleWeather ({postcode: '', such: Hi, location: '', unit: degree, success: function (weather) {if (continent == ' America ') {Html =' & lt; p & gt; '+ weather.city +', '+ Weather.region +'  ';} Other {html =' & lt; p & Gt; 'weather.city +', '+ Weather.country +' & lt; / p & gt; ';} // html + =' & lt; p class = "time" id = "'+ city + '& Gt; & lt; / p & gt; '; // html +' & lt; p & gt; '+ weather.updated +' & lt; / p & gt; 'html =' & lt; p & gt; & lt; i class = "icon '+ Weather.code +' '& gt; & lt; / i & gt;' Weather.temp + '& amp; deg;' Weather.units.temp + '& lt; p & gt;'; Html + = '& Lt; p & gt;' + weather order + '& lt; p & gt;' $ ('# weather_' + city). Html (html);}, error: function (error) {$ ('# Weather_' + city). HTML ('& lt; p & gt;' + Error + '& lt; / p & gt;'); }}); }); $ (Function () {setInterval (function () {$ ('time'). (Function () {var city = $ (this) .attr ("city") var continent = $ (this) .attr ( "Continent"); // $ (this). Text (ct); var UPC = moment.ut (.) Format ('YYYY-MM-DD HH: mm: ss') var localtime = moment. UTC). ToDate (); CityTime = moment (lOCALTIME) .tz (continent + "/" + city) .format ('ddd d MMM yyyy, h: mm: ss a z'); $ (this) .text (city + ' : 'Citytime);});}, 1000);}); $ ('Time'). Each (function () {var city = $ (this) .attr ("city"); // $ ('# weather_' + city). Later (this);}); });  

You can then relate to that & lt; You can use the method to attach to div & gt. ;

  $ (this) .text (city + ':' citytime) .appendTo ("div [city = '" + City + ''] ");  


Comments

Popular posts from this blog

winforms - C# Form - Property Change -

java - Messages from .properties file do not display UTF-8 characters -

javascript - amcharts makechart not working -