Qualify After deleting "href"...">

How to remove "href" using jQuery?

<a id="a$id" onclick="check($id,1)" href="javascript:void(0)" class="black">Qualify</a> 

After deleting "href", is "Qualification" still clickable?

+43
jquery href
Nov 06 '09 at 14:51
source share
4 answers

Your title question and your example are completely different. I will start by answering the title question:

 $("a").removeAttr("href"); 

And if href is not required, the generally accepted way to do this is:

 <a href"#" onclick="doWork(); return false;">link</a> 

Returning false is necessary so that href does not actually go anywhere.

+88
Nov 06 '09 at 14:56
source share
— -

If you want your anchor to still display, you can click:

 $("a").removeAttr("href").css("cursor","pointer"); 

And if you want to remove href only from bindings with certain attributes (for example, those that have only a hash tag like href - this can be useful in asp.net)

 $("a[href='#']").removeAttr("href").css("cursor","pointer"); 
+18
Feb 18 '11 at 19:18
source share

If you remove the href attribute, the anchor will not be configured and will look like plain text, but it will still be clickable.

+8
Nov 06 '09 at 14:58
source share

If you want to remove href, change the cursor and also do not click on it, this should work:

$("a").attr('href', '').css({'cursor': 'pointer', 'pointer-events' : 'none'});

+7
Sep 09 '15 at 6:16
source share



All Articles