Adding items to jQuery array using push on click -


link

this kind of thing have, , push , splice working marvellously. want add(push) items when click on sort of button.
like: button click... data.items.push(anything)... , appears in list (the array using list). link

enter move , type input boxes , click button, add movie , type , unique id in object.

var data = {items: [     {id: "1", name: "snatch", type: "crime"} ]};  $('button').on('click',function(){     var name = $('#name').val();     var type = $('#type').val();     var id = parseint(data.items[data.items.length-1].id)+1;      data.items.push({"id":id.tostring(), "name":name,"type":type});     console.log(data); }); 

demo


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -