INDEX.HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="static/css/index.css">
</head>
<body>
输入:
<br>
<textarea class="input" name="" id="" cols="30" rows="10"></textarea>
<br>
<BUTTon>Run</BUTTon>
<br>
输出:
<pre></pre>
<script type="module">
import {
main
} from "/static/js/indx.js"
main();
</script>
</body>
</html>
INDEX.CSS
textarea {
width: 500px;
height: 300px;
background-color: lightblue;
font-size: 24px;
}
pre {
width: 500px;
height: 300px;
background-color: lightgray;
font-size: 24px;
}
INDX.JS
let input = document.querySelector(".input");
let run = document.querySelector("button");
let output = document.querySelector("pre");
//获取第一个满足要求的标签
function main() {
run.addEventListener("click", function () {
let s = input.value;
output.innerHTML = s;
});
}
export {
main
}