Home  >  Article  >  Web Front-end  >  js 取消超链接的方法小结_javascript技巧

js 取消超链接的方法小结_javascript技巧

WBOY
WBOYOriginal
2016-05-16 18:01:111372browse
单个链接取消链接并触发js事件
复制代码 代码如下:

批量将网页中的链接取消或重新设置链接的代码:

[Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]

如果想让指定id的链接字取消或恢复链接可以参考下面的代码
复制代码 代码如下:

var e=document.getElementById( "link1 ")
//设置
e.setAttribute( "href ",e.rel)
//取消
e.setAttribute( "rel ",e.href)
e.removeAttribute( "href ")

代码说明:为什么取消需要加上e.setAttribute( "rel ",e.href) ,这段代码就是为a增加一个rel熟悉并设置好链接,方便后来的恢复链接。
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn