The function I am using now is:
<div class='edit' data-sort='1'></div>
<div class='edit' data-sort='4'></div>
<div class='edit' data-sort='7'></div>
<div id="as"></div>
exist = $('.edit').length;
var valuer=new Array();
if(exist > 1) {
valuer = $('div[data-sort]').attr('data-sort');
$('#as').append(valuer);
}
But the array ‘valuer’ only captures the first value, appending the number 1 to the div ‘#as’
How can I capture all of the values, and then append them to the div ‘#as’?
You need use the .each() for looping each HTML element found on your selector. Like: