1

I want to disable 'a' tag inside div using jQuery.

The structure is like:

<div id="xyz"><a style="cursor:pointer;" href="abc.php">xxxx</a></div>

On a particular action:

  1. cursor: pointer property should go away
  2. action on 'a' tag should not work
  3. 'a' tag should looks like non clickable
VisioN
  • 143,310
  • 32
  • 282
  • 281

3 Answers3

3

Here you are:

$("#xyz a").css("cursor", "auto").removeAttr("href");
VisioN
  • 143,310
  • 32
  • 282
  • 281
1

Hi You can use this css lines

#xyz a{
   pointer-events: none;
   cursor: default;
}

Disable link using css

Community
  • 1
  • 1
Miqdad Ali
  • 6,129
  • 7
  • 31
  • 50
0

You can use prevent the default action of a tag using

  $('#xyz a').click(function(event){
        event.preventDefault();
    });

Demo

Sibu
  • 4,609
  • 2
  • 26
  • 38