正在删除href属性
Removing the href attribute
我正在尝试编写一个分页代码。一个功能是禁用当前链接,使其看起来像文本,并且不可点击。在html页面中,这可以通过省略href属性来实现,如:
<a>Link</a>
我在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>
?
尝试此removeAttribute("href")
尝试附加的代码片段。它使用javascript,目前删除了指向第三个链接的链接函数。您可以通过在javascript中添加更多的行来反映您想要删除链接的行(但保留文本),从而轻松地对其进行调整。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<a id="test-1" href="test-1">test-1</a>
<a id="test-2" href="test-2">test-2</a>
<a id="test-3" href="test-3">test-3</a>
<script>
document.getElementById("test-1").removeAttribute("href");
</script>
</body>
</html>
相关文章:
- 锚点元素的href属性自动更改
- href属性内的javascript函数
- 如何提取“;href"最近列表项中的属性值
- 点击获取jQuery上的href属性
- href属性在页面加载后拒绝重新设置
- 使用水豚,i'm无法从href中读取自定义数据-属性
- 使用 Div 标签的 location.href 属性时,Eval 不起作用
- 如何在 jQuery 中将 HTML 标记的 HREF URL 替换为不完整的属性
- 将定位点的 href 属性与“#”进行比较
- SEO机器人是否总是遵循A标签的href属性中的URL,即使点击/点击被Javascript拦截
- 如何删除锚标记的 href 属性内的 #
- 将属性添加到带有href链接但没有#的元素
- 如何防止jQuery在单击时更改href属性
- 当锚点的属性“href”包含javascript时,在后台打开链接
- 此时不允许在元素按钮上使用属性 href
- 在 jsp 中属性 href 的错误值
- 无法设置属性'href'未定义或空引用的
- Jquery - 如何重定向到上一页并在单击链接后在 url 中添加属性 href
- Jquery -如何在链接中更改部分属性href
- 如何删除链接或打开子元素,如果链接属性href包含字符串,我需要找到