jquery 重复执行

场景:jQuery 在after或许appten的时候如果代码中包含javascript会被重复执行

jQuery 在after或者appten的时候如果代码中包含javascript会被重复执行

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

<html>

    <head>

        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

        <title>Untitled Document</title>

        <script type="text/javascript" src="./jquery-1.4.3.min.js">

        </script>

        <script type="text/javascript">

            $(function(){

                $("#tBtn").click(function(){

                    $("#a").after($("#b"));

                })

                $("#tBtn1").click(function(){

                    $("#a").append($("#b"));

                })

            })

        </script>

    </head>

    <body>

        <div id="a">

            <input type="button" value="test" id="tBtn"/>

<input type="button" value="test1" id="tBtn1"/>

        </div>

        <div id="b">

            <p>

                p

            </p>

            <script type="text/javascript">

                $(function(){

                    alert("test");

                })

            </script>

        </div>

    </body>

</html>