删除href属性 [英] Removing the href attribute

查看:110
本文介绍了删除href属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编写用于分页的代码.一种功能是禁用当前链接,使其看起来像文本并且不可单击.在html页面中,可以通过省略href属性,例如

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>

我无法在javaScript中做到这一点,

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;
}

因为

this.current.href = null;

产生

<a href="null">Link</a>

我也尝试了this.current.href=""this.current.disabled=true,但是它们都不起作用. 如何实现<a>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>?

推荐答案

尝试此 removeAttribute("href")

这篇关于删除href属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆