jQuery addClass example
Change class name on click in jQuery
by Simplybj
HTML
<button>Change color</button>
CSS
button {
background: #0084ff;
border: none;
border-radius: 5px;
padding: 8px 14px;
font-size: 15px;
color: #fff;
}
JavaScript
function GetWeatherData(){
$.ajax({
async: true,
cache: false,
type: 'Get',
contentType: "application/json; charset=utf-8",
url: 'https://api.openweathermap.org/data/2.5/weather?APPID=109c24a73ea7276651bc6ea7888cb48b&lat=35&lon=139',
dataType: 'json',
success: function (data) {
console.log(data);
},
error: function(){
}
});
}
// find elements
var button = $("button")
// handle click and add class
button.on("click", function(){
GetWeatherData();
})