About using links to run functions.

    The fashionable fight for semantic purity code, we should abandon the practice of the following code:

    Click!

    In one article is offered instead of the following code to the jQuery:

    Click!

    $('a.doSomething').click(function(){ ... }

    Yes, the HTML5 specification is written: «The href attribute on a hyperlink element must have a value that is a valid URL This URL is the destination resource of the hyperlink. " But it turns out that when you use a link to launch some AJAX loading of a part of the page, the link tag, instead of what it was supposed to, launches the function. And the proposed option also provides a link to a non-existent file.

    Moral: to use AJAX actions use BUTTONS and not links.

    Thanks for attention.

    Also popular now: