Unlink a single link and trigger a js event
Copy codeThe Code is as follows:
<A href = "javascript: void (0);" onclick = "alert ('OK')"> test </a>
Code for canceling links in multiple webpages or resetting links:
Download the software material from the Baidu script home server webmaster query script <input type = button id = o1 value = "cancel all links" onclick = "javascript: doLinkAll (false) "> <input type = button id = o2 value =" Reset link "onclick =" javascript: doLinkAll (true) "> <script> function doLinkAll (action) {var arr = document. getElementsByTagName ("A") for (var I = 0; I
[Ctrl + A select all Note: If you need to introduce external Js, You need to refresh it to execute]
If you want to cancel or restore the link of the specified id, refer to the following code:
Copy codeThe Code is as follows:
Var e = document. getElementById ("link1 ")
// Set
E. setAttribute ("href", e. rel)
// Cancel
E. setAttribute ("rel", e. href)
E. removeAttribute ("href ")
Code Description: Why do I need to add e. setAttribute ("rel", e. href) to cancel the cancellation? This Code adds a rel for a and sets a link to facilitate later link recovery.