That's because the new link has not been bound to the function
described in the first part. See here:

http://docs.jquery.com/Frequently_Asked_Questions#Why_do_my_events_stop_working_after_an_AJAX_request.3F

Although it's not added through an AJAX request the principle is the same.

On Sat, Aug 22, 2009 at 11:03 AM, za~za<zann...@libero.it> wrote:
>
> if i append an link to the page the function preventDefault() dont
> work if i click on it
>
> anyone know how to prevent default action of an appended link?
>
>
> <html>
> <head>
> <title>Page title</title>
> <script type="text/javascript" src="jquery-1.3.2.min.js"></script>
> <script language="JavaScript" type="text/javascript">
> <!--
> $(function () {
>  $("a").click(function(event){
>    event.preventDefault();
>  });
>  $('#content').append('<a href="index.php">Appended link</a>');
> });
> //-->
> </script>
> </head>
> <body>
> <a href="index.php">Normal link</a>
> <div id="content"></div>
> </body>
> </html>
>

Reply via email to