Created
June 10, 2016 10:02
-
-
Save fazo96/6a38b21dce9220580f0b90eb0bba78f6 to your computer and use it in GitHub Desktop.
Override default link behavior on all <a> tags
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(){ | |
var links = document.querySelectorAll('a[class="action"]'); | |
console.log(links) | |
for(var i = 0; i < links.length; i++) { | |
var el = links[i] | |
var href = (function(){ return el.href })() | |
var title = (function(){ return el.innerText })() | |
el.onclick = function (event) { | |
event.preventDefault(); | |
// handle click, use 'href' and 'title' | |
return false | |
} | |
el.href = '#' | |
} | |
})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment