jQuery: Disable a link

The method below is quite commonly used.  Now if you click on yahoo, you will not be brought to the web site.

<!DOCTYPE html>
<html>
    <head>
        <script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
        <title>Disable A Link</title>      
        <script>
            $(function () {
                $('a').click(function (e) {
                    e.preventDefault();
                });
            })
        </script>
    </head>
    <body>
        <a href="http://yahoo.com">Yahoo</a>
    </body>
</html>

button

Leave a comment

Leave a Reply