I'm trying to write a code for pagination. One function is to disable the current link so it looks like text and to be unclickable. In html page this could be achieved by omitting the href attribute like :
<a>Link</a>
I couldn't do that in javaScript,
AvdonPagination.prototype.manageLinks = function(link){
if(link){
this.current.href = '#';
this.current = link;
}else{
this.current = this.links[0];
}
this.current.href = null;
}
because
this.current.href = null;
produces
<a href="null">Link</a>
Also I tried this.current.href=""
, and this.current.disabled=true
, but neither of them works.
How I can achieve <a>Link</a>
?
To remove a hyperlink but keep the text, right-click the hyperlink and click Remove Hyperlink. To remove the hyperlink completely, select it and then press Delete.
The <a> tag doesn't have a disabled attribute, that's just for <input> s (and <select> s and <textarea> s). To "disable" a link, you can remove its href attribute, or add a click handler that returns false.
Definition and UsageThe href attribute specifies the URL of the page the link goes to. If the href attribute is not present, the <a> tag will not be a hyperlink. Tip: You can use href="#top" or href="#" to link to the top of the current page!
try this removeAttribute("href")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With