将这段代码写入原来html
时间: 2023-12-07 19:02:31 浏览: 137
好的,你可以将以下代码复制粘贴到原来的 HTML 文件中的 `<head>` 和 `<body>` 标签之间:
```html
<!DOCTYPE html>
<html>
<head>
<title>Math Board</title>
<link rel="stylesheet" type="text/css" href="./style.css" />
<meta charset="utf-8" />
<!-- <meta name="viewport" content="width=device-width, initial-scale=1.0" /> -->
<script type="text/javascript" src="./src/code.js" defer></script>
<!-- MathJax -->
<script id="MathJax-script" type="text/javascript" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js" async></script>
<script type="text/javascript">
function createBox() {
var inputText = document.getElementById('input').value;
var textElement = document.createElement('div');
textElement.innerHTML = inputText;
document.body.appendChild(textElement);
}
</script>
</head>
<body>
<div id="env">
<canvas id="painting-area"></canvas>
</div>
<div id="bar">
<div id="paint">
<button onclick="changeTool(0)">文本框</button>
<button onclick="changeTool(1)">画笔</button>
<button onclick="changeTool(2)">橡皮擦</button>
</div>
<div id="text">
<form name="form" onsubmit="return false;">
<textarea id="input" autofocus></textarea>
<button id="button" onclick="createBox();">▷</button>
</form>
</div>
</div>
</body>
</html>
```
在这段代码中,我添加了一个 `createBox()` 函数,它会在点击"▷"按钮时创建一个 `<div>` 元素,其中包含文本框中输入的内容,并将其添加到页面的 `<body>` 中。请确保将这段代码替换原来的 HTML 文件中的相应部分,并保存文件。然后你可以在浏览器中打开修改后的 HTML 文件来查看效果。
阅读全文
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)