How would I go about creating an array containing each link title from the following? (Link 1, Link 2, Link 3) - I'm trying to pass this data through a load() command so it then pre-caches the results to reduce load time if the user decides to click on one of the links.. (each link calls to an api fetching data related to the title)
<ul id="links">
<li><a href="#" title="Link 1">Link 1</li>
<li><a href="#" title="Link 2">Link 2</li>
<li><a href="#" title="Link 3">Link 2</li>
</ul>
My idea:
var elems = document.getElementsByTagName("#links li a");
var arr = jQuery.makeArray(elems);
??
But i'm not sure how to get just the title attr() of each link and send it over as an array
Thank you
:D
Perhaps it's better to use each() and then have the load() within that, so it makes independent load calls recursively?
Something like this instead:
$("#similar-artists li a").each(function() {
alert("alert"); // load();
});
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…