簡體   English   中英

如何在 HTML 中顯示 console.log

[英]How to display console.log in HTML

如何在 html 中顯示console.log
我嘗試了很多東西,但無法得到它。
我希望這個out.guild.members.length顯示在 html 中。 有人可以幫助我嗎?

謝謝!

let url = 'MyURL';

fetch(url)
// Send an HTTP request to the API using fetch.
.then(res => res.json())
// Parse the data as JSON.
.then((out) => {
  console.log(out.guild.members.length);
  // Retrieve the member count.
 
})
.catch(err => { throw err });

我不太明白你的問題,但如果你想在 HTML 的某個 div 中顯示out.guild.members.length ,你可以在 HTML 中添加一個 div。

HTML:

<div id="log"></div>

JS:

document.getElementById("log").innerHTML=out.guild.members.length;

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM