-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