I am getting myself confused with the DOM.
I have this HTML:
<div class="my-list">
<div class="name"></div>
<div class="title"><a href="some_url"></a></div>
</div>
<div class="my-list">
<div class="name"></div>
<div class="title"><a href="some_url"></a></div>
</div>
And this JavaScript:
var myList = $(".my-list");
for (var i=0; i < myList.length; i++) {
// what I want is at myList[i] to get the
// $(".title a").attr("href") as a variable
// and then put this variable as text
// into the html of the $(".name") html
}
What is a good way to construct this?
1 Answer