[英]how can I stop the trigger of the outer div event when I click the inner element? And all the events are bound to $(document.body)
[英]How can I use document.body to append a table that will be placed in a specific DIV
在我復制表格之后。 我想把這個新表放在一個名為 div1 的特定 DIV 中。 我如何將 append 新表轉到 div1?
<div
id="div1">
</div>
var elementz = document.getElementsByTagName("table")[1]; //cloning a table
var table = elementz.cloneNode(true);
document.body.appendChild(table);
<!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>
</head>
<body>
<table>
<tr>
<td>Hello</td>
</tr>
</table>
<div id='div1'></div>
<script>
const div1 = document.getElementById('div1')
const table = document.getElementsByTagName('table')[0];
const newTable = table.cloneNode(true); //cloning a table
div1.appendChild(newTable);
</script>
</body>
</html>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.