Javascript 不在同一行输出结果
Javascript doesnt output the result at the same line
我在使用这段代码时遇到了一些问题
<div id="ip"></div>
<div id="city"></div>
<div id="land"></div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script>
$.get("https://api.ipdata.co?api-key=test", function (response) {
$("#ip").html("IP: " + response.ip);
$("#city").html(response.city + ", " + response.region);
$("#land").html(response.country_name + ", " + response.region);
$("#response").html(JSON.stringify(response, null, 4));
}, "jsonp");
</script>
我希望结果显示在同一行而不是这样
enter image description here
我什么都试过了,但就这样结束了。我需要帮助!我需要 ip 地址和城市名称应该在同一行
像这样?为什么不把所有东西都放在同一个 div 中,这对我来说似乎是更简洁的解决方案,也是我的方法。
<div id="wrapper"></div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script>
$.get("https://api.ipdata.co?api-key=test", function(response) {
$("#wrapper").append("IP: " + response.ip);
$("#wrapper").append(" " + response.city + ", " + response.region);
$("#wrapper").append(" " + response.country_name + ", " + response.region);
$("#response").html(JSON.stringify(response, null, 4));
}, "jsonp");
</script>
我在使用这段代码时遇到了一些问题
<div id="ip"></div>
<div id="city"></div>
<div id="land"></div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script>
$.get("https://api.ipdata.co?api-key=test", function (response) {
$("#ip").html("IP: " + response.ip);
$("#city").html(response.city + ", " + response.region);
$("#land").html(response.country_name + ", " + response.region);
$("#response").html(JSON.stringify(response, null, 4));
}, "jsonp");
</script>
我希望结果显示在同一行而不是这样 enter image description here 我什么都试过了,但就这样结束了。我需要帮助!我需要 ip 地址和城市名称应该在同一行
像这样?为什么不把所有东西都放在同一个 div 中,这对我来说似乎是更简洁的解决方案,也是我的方法。
<div id="wrapper"></div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script>
$.get("https://api.ipdata.co?api-key=test", function(response) {
$("#wrapper").append("IP: " + response.ip);
$("#wrapper").append(" " + response.city + ", " + response.region);
$("#wrapper").append(" " + response.country_name + ", " + response.region);
$("#response").html(JSON.stringify(response, null, 4));
}, "jsonp");
</script>