Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- x = [{"id":"item1","val":"Items"},{"id":"item1","val":"Items"},{"id":"item1","val":"Items"}]
- var clickId = // could be "item1", "item2"....
- var found = $.inArray(clickId, x); //
- if(found >=0)
- {
- x.splice(found,1);
- }
- else{
- x.push(new Item(clickId, obj)); //push json object
- }
- x = [
- {"id":"item1","val":"Items"},
- {"id":"item1","val":"Items"},
- {"id":"item2","val":"Items"}
- ];
- var clickId = [];
- var list = JSON.parse(x);
- $.each(list, function(index, value){
- if(clickId.indexOf(value.id) === -1){
- clickId.push(value.id);
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement