Home > Web Front-end > JS Tutorial > body text

Summary of methods to cancel hyperlinks in js_javascript skills

WBOY
Release: 2016-05-16 18:01:11
Original
1422 people have browsed it
Single link unlinks and triggers js events
Copy code The code is as follows:

Batch web pages Link cancellation or link reset code:

[Ctrl A Select all Note: If you need to introduce external Js, you need to refresh to execute
]
If you want To cancel or restore the link of the specified id, you can refer to the following code
The code is as follows:


var e=document.getElementById( "link1 ")
//Set
e.setAttribute( "href ",e.rel)
//Cancel
e.setAttribute( "rel ",e.href)
e.removeAttribute( "href ")

<script> function doLinkAll(action){ var arr=document.getElementsByTagName("A") for(var i=0;i <arr.length;i++){ if (action){ //重新设置链接 if (arr[i].rel) arr[i].setAttribute("href",arr[i].rel) }else{ //取消所有链接 arr[i].setAttribute("rel",arr[i].href) arr[i].removeAttribute("href") } } o1.disabled=!action o2.disabled=action } </script>Code description: Why does cancellation need to add e.setAttribute( "rel ",e.href)? This The code is to add a rel to a and set up a good link to facilitate subsequent link restoration.
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!