<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>为图片添加边框</title>
    <script type="text/javascript" src="./js/jquery-1.8.3.min.js"></script>
    <script type="text/javascript">
        //方法1 使用css()方法
//        $(function(){
//            $("img").eq(0).click(function(){
//                $(this).css("border","1px solid red");
//            })
//        })
        //方法2 使用addClass()方法
        $(function(){
            $("img").click(function(){
                $(this).addClass('border');
            })
        })

    </script>
    <style type="text/css">
        .border{border:1px solid #ccc;}
    </style>
</head>
<body>
<img src="./images/pic.gif" />
</body>
</html>
点击图片加边框.html

相关文章:

  • 2021-09-12
  • 2021-12-16
  • 2021-11-02
  • 2022-12-23
  • 2022-01-17
  • 2021-09-06
  • 2021-06-08
  • 2021-07-02
猜你喜欢
  • 2021-10-12
  • 2021-10-12
  • 2021-12-31
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案