-_-#【JS】element.click()

时间:2023-03-09 16:23:57
-_-#【JS】element.click()
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<button>click</button>
<script>
document.getElementsByTagName('button')[0].onclick = function() {
alert(2)
}
document.getElementsByTagName('button')[0].click()
</script>
</body>
</html>