function citySearchList() {
      $("#cityList").empty();
      var count = 0;
      for (var i = cities.length-1; i >= 0; i--) {
        if (count++ < 9) {
          var newBtn = $("<button>").attr("class", "listBtn btn").attr("city-name", cities[i]).text(cities[i]);
        $("#cityList").append(newBtn);
        }
      }
      $(".listBtn").on("click", function (event) {
        var city = $(this).text();
        weatherData(city);
      })
    }
//Dynamically building City List under search box
Dynamically building City List under search box
Dynamically building City List under search box
function citySearchList() {
      $("#cityList").empty();
      var count = 0;
      for (var i = cities.length-1; i >= 0; i--) {
        if (count++ < 9) {
          var newBtn = $("<button>").attr("class", "listBtn btn").attr("city-name", cities[i]).text(cities[i]);
        $("#cityList").append(newBtn);
        }
      }
      $(".listBtn").on("click", function (event) {
        var city = $(this).text();
        weatherData(city);
      })
    }
function citySearchList ( ) { $ ( "#cityList" ) . empty ( ) ; var count = 0 ; for ( var i = cities . length - 1 ; i >= 0 ; i -- ) { if ( count ++ < 9 ) { var newBtn = $ ( "<button>" ) . attr ( "class" , "listBtn btn" ) . attr ( "city-name" , cities [ i ] ) . text ( cities [ i ] ) ; $ ( "#cityList" ) . append ( newBtn ) ; } } $ ( ".listBtn" ) . on ( "click" , function ( event ) { var city = $ ( this ) . text ( ) ; weatherData ( city ) ; } ) }
Dynamically building City List under search box
Dynamically building City List under search box