function titleCase(str) {
var sel = str.toLowerCase().split(" ");
var res = [];
for ( var i = 0 ; i < sel.length ; i++) {
res += sel[i][0].toUpperCase()+sel[i].slice(1)+ " ";
}
res = res.replace(/\sthe\s/gi, " THE ");
res = res.replace(/\sof\s/gi, " OF ");
return res;
}
titleCase("I'm a little tea pot");
!important
it's rarely if ever needed
:cookie: 490 | @ezioda004 |http://www.freecodecamp.org/ezioda004
$(document).ready(function(){
var url = "https://fcc-weather-api.glitch.me/api/current?";
var api;
if (navigator.geolocation){
navigator.geolocation.getCurrentPosition(function(pos){
api = url + "lat=" + pos.coords.latitude + "&" + "lon=" + pos.coords.longitude;
$.getJSON(api, (function(data){
$("#loc").html(data.name + ", " + data.sys.country);
$("#temp").html(data.main.temp + "<button id='C' class='btn btn-default'><b>C</b></button>");
$("img").attr("src", "http://openweathermap.org/img/w/" + setIcon(data.weather[0].id) + ".png");
function setIcon(num){
if (200 <= num && num <= 232){
return "11d";
} else if ((300 <= num && num <= 321) || (520 <= num && num <= 531)){
return "09d";
} else if (500 <= num && num <= 504){
return "10d";
} else if (num == 511 || 600 <= num && num <= 622){
return "13d";
} else if (num == 800){
return "01d";
} else if (num == 801){
return "02d";
} else if (num == 802){
return "03d";
} else if (num == 803 || num == 804){
return "04d";
} else {
return "01d";
}
}
}));
});
}
$(".btn").css("color", "orange");
});
Why is my final jQuery statement not effecting the button after it is created in the initial function?
:cookie: 316 | @njm8 |http://www.freecodecamp.org/njm8