A jquery means to the end of changing every(as in each and all) href value to a corresponding array value
my question is while vague, specific. I would like to know the simplest means of changing each and every (10+) anchor tags href value to a corresponding array item. the page in question being constructed from the bottom up meaning that each new post is above the last new post, so I have an array of links starting with the link that corresponds to the bottom most and thereby first placed and last in order post. so far (in theory) I think that a variable that returns each array value a reverse traversal of that array that is used in a function that selects and traverses each anchor tag would be the solution.
var standard_anchor = new Array();
standard_anchor[0] = "http://whatever.com/";
standard_anchor[1] = "http://www.egs.edu/faculty/jean-baudrillard/articles/simulacra-and-simulations-viii-the-implosion-of-meaning-in-the-media/";
var standard = $(function(){
//should return reversed iterated standard anchor array
});
////
$('a [href]').each(function(){return (standard)});
that'开发者_JS百科s as much as I can imagine.
You can use document.links, it's a live collection so you only need one reference, it will update as the DOM is updated.
You can iterate over it backwards using a while loop:
var links = document.links;
var i = links.length;
while (i--) {
// do stuff with links[i]
}
精彩评论