Adding text from div to another div atribute inside a (stackoverflow problem)

Problem posted: 07/08/2015

url: http://stackoverflow.com/questions/31871404/how-to-add-text-in-the-data-attribute-using-jquery
fiddle: http://jsfiddle.net/eugensunic/0kourse6/4/

Problem description:

The title says it all. The user wanted to fetch the text from the div tag and assign it to the

attribute which had a parent li.

Solution to the problem:

var array=[];
$('.pin_head > div').each(function (index,obj) { 

   array[index]= $(this).text();

});

$('li > div').each(function (index,obj) {
    var data= $(this).attr("data-col",array[index]);
});