I want to disable a hyperlink so that if user clicks on the link, nothing happens and the link is displayed in a grey color to look like it is disabled. Below is the hyperlink in html:
<span href="#" class="showGrid">[Open Grid]</span>
Below is the jquery code I am using to try and disable the hyperlink but it is not disabling it:
$(".showGrid").attr("disabled", "disabled");
How do you disable a hyperlink?
Also I have a the hyperlink displayed on the top and in each row added which uses the same class (it needs the same class for both hyperlinks to work the way I want it to). How can I disable the hyperlink in the html code below and not the hyperlink in the jquery code?
Below is hyperlink in full html:
<table id="optionAndAnswer" class="optionAndAnswer">
<tr>
<th colspan="2">
Option and Answer
</th>
</tr>
<tr class="option">
<td>Option Type:</td>
<td>
<div class="box">
<input type="text" name="gridValues" class="gridTxt maxRow" readonly="readonly" />
<span href="#" class="showGrid">[Open Grid]</span>
</div>
</td>
</tr>
</table>
Below is hyperlink in jquery code:
function insertQuestion(form) {
var $tr = $("<tr class='optionAndAnswer' align='center'></tr>");
var $options = $("<td class='option'></td>");
$('.gridTxt', context).each( function() {
var $this = $(this);
var $optionsText = $("<input type='text' class='gridTxtRow maxRow' readonly='readonly' /><span href='#' class='showGrid'>[Open Grid]</span>").attr('name',$this.attr('name'))
.attr('value',$this.val())
$options.append($optionsText);
});
$tr.append($options);
}