Saturday, November 13, 2010

Disable all links via jQuery

Grabbing element with jQuery is very easy. In this example i’ll disable all links using jQuery.

<script>
$(function(){
    //grab all a tags
    $('a').each(function(){
        //click on a link....
        $(this).click(function(){
            alert($(this).attr('href')+' is not available');
            //disable link
            return false;
        });
    });
});
</script>

No comments:

Post a Comment