本帖最后由 Dexlux 于 2021-7-15 21:37 编辑
[JavaScript] 纯文本查看 复制代码 <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.0.js"></script>
</head>
<body>
<table class="table">
<tr class="tr">
<td><a href="JavaScript:">a元素</a></td>
</tr>
<tr>
<td><a href="javascript:" class="add">增加</a></td>
</tr>
</table>
<script type="text/javascript">
$("tr").on("click", function () {
alert('tr被点击了');
})
$('.add').click(function () {
let td = $('<td><a href="JavaScript:">新添加的a</a></td>')
$('.tr').append(td)
})
$('td').on('click', 'a', function (e) {
e.stopPropagation();
})
</script>
</body>
</html> |