Monday, June 11, 2012

Javascript | How to disable/enable the href functionality

Problem:
It's been a couple of days since I started solving the issue of href = "#", what I want is to disable it on certain occasion. Means there would be no active link will be shown on "Visit biboyatienza blogspot!" link, it should be display as a normal text no underline no mouse over.

From : Visit biboyatienza blogspot!


To : Visit biboyatienza blogspot!


Solution:
 var chk = document.getElementById('chkShoulBeActive');  
 if(chk != null)                 
 {  
                var hl = document.getElementById('hlSite');  
                if(hl != null)  
                {  
                     if(chk.checked)  
                          hl.addAttribute('href');  
                     else       
                          hl.removeAttribute('href');  
                }  
 }  

Hope you find it helpful

No comments:

Post a Comment