Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2

Thread: jQuery append()

  1. #1
    New to the CF scene
    Join Date
    Dec 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    jQuery append()

    I have multiple list elements...

    <li result[i+1]· <a> show comments(0) </a> · <a id='submit_agree' > <img src='gif/checkmark.ico'> agree </a> · <a id='submit_disagree'><img src='gif/cross.ico'> disagree </a> · <a id='submit_offtopic'><img src='gif/commenticon.ico'> go offtopic </a>
    </li>

    <ul id='comment'>
    </ul>


    This jQuery doesn't work:
    <script type="text/javascript">
    $(document).ready(function(){
    $('a#submit_agree :selected').live('click', function(){
    $('ul#comment :selected').append("<li>This text</li>");
    });
    });

    </script>


    What I want it to do is append to the current node in the list above. The one that the user has selected. The problem is they all same ID element, and I want it to append to the one that the user has selected.

    Any ideas?

  • #2
    Senior Coder
    Join Date
    Dec 2010
    Posts
    2,396
    Thanks
    12
    Thanked 569 Times in 562 Posts
    Quote Originally Posted by coolz View Post
    The problem is they all same ID element, and I want it to append to the one that the user has selected.
    Any ideas?
    Congratulations, you have identified the problem yourself! The ID attribute of all elements on a page must be unique. It can not work otherwise.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •