how do i count Href using jquery

count, href, jquery

Solution

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.

Problem

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

Original source