[href] What does <a href="#" class="view"> mean?

In my html page, I see a link whose 'view source' code is as below :

<a href="#" class="view">

I see a valid link when I hover my mouse on it and when I click it, it works. But I am not able to find where and how this URL gets generated. I found the class a.view being defined in one of the CSS, but couldn't find the URL in the page source.. Can somebody help me out on whr i can find this URL ?

This question is related to href html

The answer is


Javascript may be hooking up to the click-event of the anchor, rather than injecting any href.

For example, jQuery:

$('a.view').click(function() { Alert('anchor without a href was clicked');});

Of course, the javascript can do anything it wants with the click event--such as navigate to some other page (in which case the href is never set, but the anchor still behaves as though it were)


It probably works with Javascript. When you click the link, nothing happens because it points to the current site. The javascript will then load a window or an url. It's used a lot in AJAX web apps.


The href is probably generated in a javascript function. For example with jQuery:

$(function() {
    $('a.view').attr('href', 'http://www.google.com');
});

Don't forget to look at the Javascript as well. My guess is that there is custom Javascript code getting executed when you click on the link and it's that Javascript that is generating the URL and navigating to it.