how can i disable anchor link using jQuery or HTML?


I would like to disable anchor link (<a>)in my HTML, making it non-clickable?

It doesn't have any URL, but It is clickable and redirect to same to the page, here is code.

<a href="{{URL}}" class="user-notification-item  user-notification-item-unread">
                        <span class="details">
                            <i class="fa fa-check"></i> Test
                        </span>
                        <div>
                            <span class="notification-time" title="2018-01-12 14:26:08">4 minutes ago</span>
                            <span>
                                -
                                <span data-notification-id="d2f07dcc-1d51-49e0-9d6f-109cd4bdd405" class="set-as-read-text set-notification-as-read">set as read</span>
                            </span>
                        </div>
                    </a>

I would like to disable it using CSS or with some jquery/javascript, so how can i do it?


Asked by:- jon
1
: 3536 At:- 1/12/2018 2:38:23 PM
HTML disable anchor tag make anchor tag non-clickable jquery







1 Answers
profileImage Answered by:- manish

You can disable anchor link easily using these ways:

1. Using HTML, by making href="#"

<a href="#">Some text here</a>

2. Using HTML, by making href="javascript:void(0)"

<a href="javascript:void(0)">Some text here</a>

3. Using jQuery

$(function () {
   //Get all <a> who has class AchorClass 
    $('a.AchorClass').on("click", function (e) {
        //make it non-clickable using this code
        e.preventDefault();
    });
});

4. Using CSS

a.AchorClass{
    pointer-events: none;
}
2
At:- 1/14/2018 3:13:34 PM
Thanks 0
By : jon - at :- 1/15/2018 11:25:20 AM






Login/Register to answer
Or
Register directly by posting answer/details

Full Name *

Email *




By posting your answer you agree on privacy policy & terms of use