-3
我想通過從輸入字段中獲取的值來提醒address2。我一直沒有得到。請幫助如何在jquery或javascript中連接另一個var字符串中的var?
HTML
<form>
<div class="form-group">
<input class="form-control" id="city" type="text">
</div>
<button id="locationWeather" onclick="check()" type="button">Submit</button>
</form>
我的腳本
function check() {
var address = $("#city").val();
var address2 = "https://maps.googleapis.com/maps/api/geocode/json?address=" +address "&key=YOUR_API_KEY";
alert(address);
alert(address2);
}
</script>
您在地址後缺少+號。 – Brandon
在瀏覽器中打開開發者控制檯。它會指出你的錯誤。 – epascarello