开发者

Jquery: Select a href link and navigate with 'each' method

Is it possible using jQuery to select one full link that is in others 'tags'?

I would li开发者_StackOverflow社区ke select each href link of each item (<li>)..

My idea is to use the method each and then extract the link, for use to navigate then.

This is the part of the code of the page: http://pastebin.com/3Vjib4UR

Where in full code of page, there more <li> items in the <ul> tag.

P.S: I would like use the script in an external plugin of firefox (Greasemonkey),and not direct in the page.

Thanks in advance.

Kind regards.


Or shorter:

var links = $('a').map(function(){ return this.href;}).get();

If you want to get only certain links, just adjust the selector, e.g.

$('ul li a')

You really should learn how selectors works in order to use jQuery efficiently.


Like this?

var arr = new Array();

$("a").each(function(){ arr.push($(this).attr("href"); });
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜