This tests blocking a link '<a>' on a page. The link below looks normal, but if you click on it, an alert appears and you do not go anywhere.

jQuery

Code is:

    <p><a class="content_href" href="//jquery.com/">jQuery</a></p>
    <script src="/scripts/jquery-1.7.2.js"></script>
    <script>
        $(document).ready(function(){
            $("a.content_href").click(function(event){
                alert("As you can see, the link no longer took you to jquery.com");
                event.preventDefault();
            });
            $("a.content_href").addClass("test");
            $("a.content_href").click(function(event){
                event.preventDefault();
                $(this).hide("slow");
            });
        });
    </script>
                

Back to Testing