<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <style type="text/css">
    .imgclass{ width:200px; height:200px;}
    </style>
    <script src="jquery-1.9.1.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(function () {
            $('#img1').click(function () {
                //如果clone()方法的参数为true,则此元素的事件也会被复制,如果为空(默认为false),则事件不会被复制
                $(this).clone(true).appendTo('div');
            })
            $('#img1').mouseover(function () {
                alert('ok');
            })
            $('#Button1').click(function () {
                alert($('img').length);
            })
            $('#Button2').click(function () {
                //$('#img1').attr('src','images/3.jpg');
                //alert($('#img1').length);
                //无论复制多少份,无论参数是否为true,无论复制之后,复制品的id是否与正品的Id一样,文档中始终只有一个此id的元素。
                alert($('.imgclass').length);
            })
        })


    </script>
</head>
<body>
<img src="images/2.jpg" ></html>

相关文章:

  • 2022-12-23
  • 2021-09-28
  • 2021-06-19
  • 2022-12-23
  • 2022-02-08
  • 2022-12-23
  • 2021-12-26
猜你喜欢
  • 2022-12-23
  • 2021-09-30
  • 2021-12-18
  • 2021-12-18
  • 2022-01-07
  • 2021-10-11
相关资源
相似解决方案