jQuery如何给元素增加click事件
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
<script src="jquery-3.6.0.min.js"></script>
<script type="text/javascript">
$(function(){
})
</script>
<style type="text/css">
.aa{
width: 100px;
height: 100px;
background-color: #CF7B7C;
float: left;
}
</style>
</head>
<body>
<div class="aa">
</div>
<div id="bb">
<div></div>
<div></div>
<div></div>
</div>
</body
</html>比如我要点击class="aa" div元素,我们可以这样做,
<script type="text/javascript">
$(function(){
$('.aa').click(function(){
alert("ccc")
});
});
下一篇: jQuery 如何让元素实现隐藏与显示的效果
上一篇:jQuery 如何查询元素







评论