I have twelve <span>‘s with the class “has_title”. Each has a unique title.
I also have twelve <div>‘s with the class “bar”.
I need to assign the titles from the <span>‘s in the order that they appear in the html to the <div>‘s in the order that they appear in the html.
My idea was to use .each to store the titles in an array and then somehow loop through the array applying the titles to each of the <div>‘s in turn
So far I have the following code which stores the values of the titles in an array:
var myarr = [];
$(".has_title").each(function(){
myarr.push({ title: this.title});
});
And the following that loops through the array:
$.each(myarr, function() {
// What goes here?
});
That’s where I get stuck though. Am I even going about this in the right way?
A little help would be great as I am about to throw my laptop through the window.
Try something like this: