Disable link in paging menu in jQuery [duplicate]

0

I have a paging plugin done in jQuery. What I can not do is when I'm on the last page, the link that gives access to the next page is disabled and the user can not click any more. In the same way the button gives access to the previous page. I already followed some tips, like inserting "disable" but this does not work. Add the "little hand" in the link but you can still click. The following method was created to customize the two link's

function tagNextPrev() {
        if($nav_panels.children('.last').hasClass('active_page')){
            $nav_panels.children('.next_link').add('.last_link').removeClass('.next_link').addClass('no_more');
        } else {
            $nav_panels.children('.no_more').add('.last_link').removeClass('no_more');  
        }

        if($nav_panels.children('.first').hasClass('active_page')){
            $nav_panels.children('.previous_link').add('.first_link').addClass('no_more');
        } else {
            $nav_panels.children('.previous_link').add('.first_link').removeClass('no_more');
        }
    }
    
asked by anonymous 26.02.2014 / 19:09

1 answer

3

You can use pointer-events to prevent clicking on elements that have this class. So in your class use:

.no_more{
    pointer-events: none;
}

You can read about more variants here, but I think CSS is the best, although it only works in more modern browsers: How to prevent a click on a link / anchor or element with event tied

    
26.02.2014 / 19:12