jQuery弹框点击事件

先看看托图片:
在这里插入图片描述紧接着就是代码了:

<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
    <script src="jquery.js"></script>
    <style>
        p{
            width: 200px;
            height: 50px;
            background-color: aqua;
        }
    </style>
</head>
<body>
<center>
<h2>点击当前的p标签,弹出相对应的元素下标</h2>
    <p>1</p>
    <p>2</p>
    <p>3</p>
    <p>4</p>
</center>

<script>
    $(function () {
        $("p").click(function () {
            alert($(this).index())
        })
    });
</script>

</body>
</html>
发布了27 篇原创文章 · 获赞 45 · 访问量 2665

猜你喜欢

转载自blog.csdn.net/weixin_45746635/article/details/102767469