js .click()
程序员文章站
2022-03-19 15:00:22
...
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>click demo</title>
<style>
p {
color: red;
margin: 5px;
cursor: pointer;
}
p:hover {
background: yellow;
}
</style>
<script src="https://code.jquery.com/jquery-3.5.0.js"></script>
</head>
<body>
<p id = "fir">First Paragraph</p>
<p>Second Paragraph</p>
<p>Yet one more Paragraph</p>
<script>
$( "p" ).click(function() {
$(this).slideUp();
});//绑定一个方法在点击时触发该方法
$("#fir").click();//执行click
</script>
</body>
</html>
上一篇: 钉钉小程序推送消息准备步骤
下一篇: Lombok的使用