这是我要显示来自我的Javascript文件的结果的index.html文件
<!DOCTYPE html>
<html>
<head>
<title>Hera-Anime-Dl</title>
</head>
<body>
<div id="header">
<h1>Hera-Anime-Dl</h1>
</div>
<input type="text" id="animeInput"=> Insert a anime title</input>
<input type="text" id="episodeInput"=> Insert a episode number</input>
<button onclick="test()">search</button>
<p id="title"></p>
<p id="number"></p>
<div id="output"></div>
<script src="./js/app.js"></script>
</body>
</html>
这是app.js文件,当我使用console.log它输出结果所以我想在索引上显示结果而不仅仅是在控制台中我希望console.log的结果显示到html页面或者只是将它显示在index.html页面上
function test(){
const ConsoleLogHTML = require('console-log-html');
const anime = require('anime-dl')
let animeInput = document.getElementById("animeInput").value;
document.getElementById("title").innerHTML = animeInput;
let episodeInput = document.getElementById("episodeInput").value;
document.getElementById("number").innerHTML = episodeInput;
const name = animeInput
const chapter = episodeInput
anime.getLinksByNameAndChapter(name, chapter).then(console.log)
}
我正在使用anime-dl NPM软件包并希望将结果显示在index.html页面上
这里是搜索动漫的anime-dl输出看起来像I want to grab information from this output and display it to the index.html
答案 0 :(得分:0)
将console.log替换为将查询作为参数的响应的函数,例如:
ES6
anime.getLinksByNameAndChapter(name, chapter).then((response)=>{
document.getElementById("output").innerHtml = response.title
})
ES5
anime.getLinksByNameAndChapter(name, chapter).then(function(response){
document.getElementById("output").innerHtml = response.title
})