Here is the index.html file I want to display the results from my Javascript file
这是index.html文件,我想显示我的Javascript文件的结果
<!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>
Here is the app.js file when I use console.log it outputs results so I want to display the results on the index not just in the console I want the results from the console.log to be displayed to the html page or just have it display on the index.html page
这是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)
}
I am using the anime-dl NPM package and want to get the result to display on the index.html page
我正在使用anime-dl NPM包,并希望将结果显示在index.html页面上
here is what the anime-dl output for the search anime looks like I want to grab information from this output and display it to the index.html
这里是搜索动漫的anime-dl输出看起来我想从这个输出中获取信息并将其显示到index.html
1 个解决方案
#1
0
Replace console.log to a function that will recieve the response of the query as parameter, for example:
将console.log替换为将接收查询响应作为参数的函数,例如:
ES6
ES6
anime.getLinksByNameAndChapter(name, chapter).then((response)=>{
document.getElementById("output").innerHtml = response.title
})
ES5
ES5
anime.getLinksByNameAndChapter(name, chapter).then(function(response){
document.getElementById("output").innerHtml = response.title
})
#1
0
Replace console.log to a function that will recieve the response of the query as parameter, for example:
将console.log替换为将接收查询响应作为参数的函数,例如:
ES6
ES6
anime.getLinksByNameAndChapter(name, chapter).then((response)=>{
document.getElementById("output").innerHtml = response.title
})
ES5
ES5
anime.getLinksByNameAndChapter(name, chapter).then(function(response){
document.getElementById("output").innerHtml = response.title
})