mainu raj kehte hai
mainu raj kehte hai

Reputation: 47

how do i count Href using jquery

I want to count the Href in a page using Jquery .

Just for refrence: i have random number of hyperlinks in a page for each user and all hrefs are diffrentiated with thier id eg. user_1,user_2,.... so here im unable to call the function on onclick event using Jquery since each href is has different name and cannot also write separate jquery functions which varies for each user . so if i could get to count hrefs in a page i could easily call the function

waiting for reply

Thanks Mukesh

Upvotes: 3

Views: 2469

Answers (3)

vvo
vvo

Reputation: 2883

$('[href]').length ? (84 in this page right now, 88 when my comment wil be on it ? :p)

Upvotes: 3

Sabeen Malik
Sabeen Malik

Reputation: 10880

i am not a js/jquery expert .. but should u be able to get back an array of "a" tags with

$("a") ?

Upvotes: 1

Gumbo
Gumbo

Reputation: 655359

Since the elements A, AREA, BASE and LINK can have a href attribute:

$('a[href], area[href], base[href], link[href]').size()

That will return the number of elements with a href attribute. The more specific the question, the more specific the answers.

Upvotes: 7

Related Questions