I'm making a Chrome app and I want to save the name and the artist of a song into a json file. I know how that can be done, but I don't know how to put in the data (here: title and artist) into a json array. We assign:
var favorites = [];
So if someone presses the star, the artist and the name of the song should be put into favorites:
$(document).on('click','.fa-star-o', function() {
var title = $(this).parent().find('.tracktitle').text(),
artist = $(this).parent().find('.artist').text();
$(this)
.removeClass('fa-star-o')
.addClass('fa-star');
$('<li/>')
.append('<span class="tracktitle">'+ title +'</span>')
.append('<span class="artist">'+ artist +'</span>')
.prependTo($favorites);
});
favoritesis an Javascript Array. Those are very different things.