I have the following data types on my <li> data-author and data-body.
When the li is clicked I would like to append the data-author and the data-info to a couple of div classes for example classOne and classTwo.
What would be the best way to get the data- when clicked and pass the data to its required location?
Code:
$(document).ready(function() {
var url = "assets/js/data.json",
fetchJSON = $.getJSON(url);
fetchJSON.done(function(response) {
var buttons = response.map(function(i) {
return $('<li>').html(i.title).attr({
"data-author": i.author,
"data-body": i.body
})
});
$('ul').append(buttons);
});
$('ul').on('click', 'li', function(){
});
}); //Ready function closed