Single link unlinks and triggers js events
Batch web pages Link cancellation or link reset code: ]
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.