JSFiddle - React, Tailwind, and code Playground

by Md. Atiquzzaman Soikat

HTML

<div class = "lang" id = "de">DE</div>
  <div class = "lang" id = "en">EN</div>
  <div class = "lang" id = "pt">PT</div>
  <div class = "language"></div>

JavaScript

var lang

$('.lang').click(function() {
   var id = event.target.id;
    $(".language").text(id)   

// I need to trigger the getWeather function with the new value for the language

   });
   var getWeather = function(data) { 
 lang = $(".language").text()
  $.getJSON('http://api.openweathermap.org/data/2.5/weather', {
        lat: data.lat,
        lon: data.lon,
        lang: lang,
        city: data.city
        })}