Well, the row element doesn't exist in the document yet, so your call to
$("#10192") won't find anything.
If you insert newrow into the document (e.g. with
$("#YourTargetElement").append(newrow)), and then do your click actions
(i.e. with $("#10192").click(function() {})), it should work.
Alternatively, you could also use the new
http://blog.brandonaaron.net/2007/08/19/new-plugin-live-query/ Live Query
plugin! :-) It takes care of all this for you.
Take care, and keep creating!
Sean
ethanpil wrote:
>
>
> Hi,
> Sorry to bother everyone with what is probably a stupid question, but
> I am new to JQuery, although loving every second...
>
> I have been trying to dynamically add and delete a table row on a
> click event, using Jquery. I am able to add and delete the row, by
> clicking on the row above it but I have not successfully been able to
> close the new row from inside of itself (using a link). I have spent 3
> or 4 hours trying all different ways to attach actions to the click
> event of the link inside my new table row, but no matter what I do, I
> cant even get an alert to popup from it.
>
> What am I doing wrong?
>
> Thanks for your time!
>
>
> $(document).ready(function(){
>
> var newrow = \'<tr id="ticket_10192" class="ticket_info"><td
> colspan="5" scope="row"><center>New Row</center><br><p align=right"> #
> Close </p></td></tr>\';
>
> $(\'#10192\').click(function(){
> var e
> if( (e=$(\'#ticket_10192\')).length ) {
> // element Exists, delete it
> $(\'#ticket_10192\').remove();
> } else {
> //Doesnt exist, create it
> $(this).after(newrow);
> }
>
> });
> $(\'a.close_ticket\').click(function(){
> $(\'#ticket_10192\').remove();
> });
> });
>
>
>
--
View this message in context:
http://www.nabble.com/Are-there-click-events-from-dynamically-added-DOM-elements--tf4311388s15494.html#a12275520
Sent from the JQuery mailing list archive at Nabble.com.