I need to use Javascript to disable a link based on its id. By default, the link is invisible. I will only enable the link when the specific id value comes from the backend.
HTML
<li id="viewroleId" style="display: none;">
<a href="viewrole"><spring:message code="label.viewrole" /></a>
</li>
Javascript:-
if (key == 1) {
var id = value;
var div = document.getElementById(id);
if(div != null){
if (div.style.display == 'none' || div.style.display == '') {
// This line will make the link visible
div.style.display = 'block';
}
}
}
In the above Javascript code, I am focusing on making the link visible. Now, how can I both display and disable the link using CSS instead?