在HTML上打印console.log [英] Print console.log on HTML

查看:43
本文介绍了在HTML上打印console.log的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个JavaScript代码,目前正在共享主机上工作.

I've a javascript code that is currently working on a shared hosting.

该脚本从网站收集数据,然后将其显示在我的网站上.

The script gather data from a website and then show it on my website.

事实是,数据显示在控制台选项卡中,而不显示在php页面中.脚本本身包含该代码:

Fact is that the data is being showed in the console tab but not on the php page. The script itself contains that code:

<script> ... function printFollowers(followersSum) {   console.log(followersSum); // you can do print followersSum wherever you want }

... </script>

但是我不明白如何打印"followersSum"函数以将其显示在HTML上.

But I don't understand how to print the "followersSum" function to display it on the HTML.

有人可以帮助我吗?

推荐答案

假设您在html的某处有< div id ="printFollower"></div> .

Let's say you have a <div id="printFollower"></div> somewhere in your html.

然后执行以下操作:

function printFollowers(followersSum) {
  document.getElementById('printFollower').innerHTML = followersSum;
  console.log(followersSum); // you can do print followersSum wherever you want
}

使用此方法,您可以控制列表显示的更好位置,应用CSS等.

Using this method, you can control where the list shows up better, apply CSS, etc.

这篇关于在HTML上打印console.log的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆