简体   繁体   中英

how to get href value in <a> tag using jQuery

Inside the html source code, there's an <a> tag with an href attribute, I want to get whatever it has after the second slash after individuals which in this case is 22284494 . The exact tag is:

<a href="/individuals/22284494" class="i-photo">

How do I do that using jQuery?

这样的事情将以锚定为目标,获取属性,在/分割并获取最后一部分

var numb = $('a.i-photo').attr('href').split('/').pop();

只是:

$(".i-photo").attr("href").split("/")[2]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM