tags:

views:

29

answers:

0

you can test my code , when i click buton , we will get 2 link

click on first link , not alert

click on second link , show alert

why first link not alert, how to it can alert ?

<html>
<head>
<script type="text/javascript" src="http://www.google.com/jsapi"&gt;&lt;/script&gt;
<script type="text/javascript">google.load("mootools", "1.1.2");</script>
<script>
    window.addEvent('domready', function(){
        $('button').addEvent('click', function(){
            $('content').innerHTML = $('test').innerHTML;
        });
    });

</script>
</head>
<body>
<input id="button" type="button" name="button" value="Click"/>
<div id="content">
</div>
<div id="test">
    <script>
        function test(){
            $('a-content').addEvent('click', function(){
                alert(1);
            });
        }
        window.addEvent('domready', function(){
            test();
        });
    </script>
    <a id="a-content" href="#">CLICK HERE</a>
</div>
</body>
</html>