Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to disable one hyperlink by clicking on second hyperlink

I have 2 hyperlinks. when i click on one hyperlink the another hyperlink should be disabled means it should be seen but not clicked by any user

Please help me

 <a href="">hiii </a> 
 <a id="check" href="google.com">bye</a>

in JavaScript

$('#check').attr('disabled', true);

but it is not working

like image 267
Delta Avatar asked Sep 05 '25 20:09

Delta


2 Answers

Using java script you can disable the hyper link by adding a .disabled class as seen below:

  .inactive //add this class to the link if you want to disable it 
{
    pointer-events: none;// this will disable the link
    cursor:default;
}

then use .inactive class in appropriate line...

like image 183
sanj Avatar answered Sep 09 '25 00:09

sanj


Try below

$('.my-link').click(function () {return false;});

To re-enable it again, unbind the handler:

$('.my-link').unbind('click');

or

$('.my-link').attr('disabled', 'disabled');

Use this to re-enable it:

$('.my-link').attr('disabled', '');

Thanks,

Siva

like image 27
SivaRajini Avatar answered Sep 08 '25 23:09

SivaRajini