using JQuery append how to push list values to another div section on button click
For example:
I have two list values
1.Adam
2.Lance
You can get the label
text using .prev() and .text()
$("button").click(function () {
var label = $(this).prev().text();
$("#sortable").append('<li>'+label+'</li>');
});
JSFiddle demo
I think that you could use this:
$(document).ready(function() {
$("button").click(function () {
$("#sortable").append('<li>'+$(this).prev('label').text()+'</li>');
});
});
Demo: https://jsfiddle.net/oa2hfLum/4/
Change
$("#sortable").append('<li></li>');
to
$("#sortable").append('<li>'+$(this).parent().find('label').html()+'</li>');