Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Removing the href attribute

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>?

like image 212
danny alkhald Avatar asked Jun 30 '13 05:06

danny alkhald


People also ask

How do you remove a href?

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.

Can I remove href from a tag?

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.

What is href =# in HTML?

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!


1 Answers

try this removeAttribute("href")

like image 179
vladkras Avatar answered Oct 06 '22 00:10

vladkras