jQuery addClass example

Change class name on click in jQuery

by It Muravshchyk

HTML

<input placeholder = 'plz' id='plz'><br><br>
<input placeholder='city 'id='placeInput'>

JavaScript

document.getElementById("plz").addEventListener("blur", fillCity);
function fillCity(){
console.log('start');
var plz = document.getElementById('plz');
var city = document.getElementById('placeInput');
console.log('>> plz:'+plz.value);
console.log('>> city:'+city.value);

$.getJSON('http://api.geonames.org/postalCodeLookupJSON?postalcode=78267&country=DE&username=sahibjot', function(data) {
    console.log('data='+data.postalcodes[0].adminName3);
	city.value = data.postalcodes[0].adminName3

});
}