Reputation: 313
I have this table:
<table class="table table-hover table-responsive">
<tbody>
<tr>
<td>1</td>
<td>2</td>
<td><a href="#">Borrar</a></td>
</tr>
</tbody>
</table>
I am using bootstrap and JQuery and I would like to disable my link in the table. I tried:
this <tr><td class="disabled"><a href="#">Borrar</td></tr>,
this <tr><td disabled><a href="#">Borrar</td></tr>,
this <tr><td><a href="#" class="disabled">Borrar</td></tr>,
this <tr><td><a href="#" disabled>Borrar</td></tr>
But this is not working.
PD: Disable with JQuery or bootstrap is good for me and I don't want to convert the link to button in bootstrap.
Upvotes: 1
Views: 1765
Reputation: 313
i tried this and worked for me.
<table class="table table-hover table-responsive">
<tbody>
<tr>
<td>1</td>
<td>2</td>
<td><a href="#" class="btn" disabled>Borrar</a></td>
</tr>
</tbody>
</table>
Thank you for your answers.
Upvotes: 0
Reputation: 115232
You can use jQuery preventDefault()
method
$('.table').on('click','a',function(e){
e.preventDefault();
//or
//return false;
});
If this method is called, the default action of the event will not be triggered.
Upvotes: 1
Reputation: 2827
you can disable all link click events by this
$('a').click(function()
{
return false;
});
.
[option]
or if you want to disable only specific link, the first give ID to that link, like:
<a href="#" id="lnk">Borrar</a>
and change JavaScript part like this:
$('#lnk').click(function()
{
return false;
});
Upvotes: 0