Uncaught syntax error: Adding <li> elements to an <ul>

Posted by ThePagan on Stack Overflow See other posts from Stack Overflow or by ThePagan
Published on 2014-05-29T21:14:21Z Indexed on 2014/05/29 21:26 UTC
Read the original article Hit count: 137

Filed under:
|
|

I keep getting an uncaught syntex error which I know usually means your code has a missing closing something. I keep failing to see what it is that I am missing.

The idea of the function is that it extracts the a links ID and Text content and add's it to an un-ordered list.

The links have a class of 'ingredient_add' and the unordered list has an ID of 'ingredientsAdded'.

I can't see what I've missed here.

$(document).ready(function() {
    $('.ingredient_add').click(function() {
        event.preventDefault();
        var id = this.id;
        var value = this.text();
        $('#ingredientsAdded').append("<li id='"+id+"'>"+value+"</li>");
    }); //end add to list
}); // end document ready()

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery