user1682076
user1682076

Reputation:

Disabling a tag inside div using jquery

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

Upvotes: 1

Views: 2229

Answers (3)

Sibu
Sibu

Reputation: 4617

You can use prevent the default action of a tag using

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

Demo

Upvotes: 0

Miqdad Ali
Miqdad Ali

Reputation: 6147

Hi You can use this css lines

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

Disable link using css

Upvotes: 1

VisioN
VisioN

Reputation: 145368

Here you are:

$("#xyz a").css("cursor", "auto").removeAttr("href");

Upvotes: 3

Related Questions