How to enable hyperlink?

There are 2 radio objects and a hyperlink. if you select "radiobutton1", the hyperlink is enabled. if you select "radiobutton2", the hyperlink is disabled. I can use jquery to disable the hyperlink, but I cannot enable it. How to enable hyperlink with jquery?

+3
source share
3 answers

You can try adding a click event handler and returning true or false from the click handler based on the state of the switches.

Returning false should cancel clicking on the link, for example:

$("#hyperlink1").click(function(){ // return true or false based on your radio buttons return enableLink; }); 
+2
source

To disable a hyperlink, you can add an onclick handler so that it returns false;

something like that:

 $("#radioDisable").click(function() { $("hyperlink").click(function(){ return false; }); $("hyperlink").addClass("disabled"); }); $("#radioEnable").click(function() { $("hyperlink").click(function(){ return true; }); $("hyperlink").removeClass("disabled"); }); 
0
source

The disabled property can be obtained and set. This property is intended for individual objects, but not for collections of objects.

 if (!$("#ContinueButton")[0].disabled) { UserContinue(); } 

write:

 $("#ContinueButton")[0].disabled = !canContinue; 
0
source

All Articles