sorry I am new to javascript but i'm working on a wordpress website and have to disable all the links on the home page from being clickable except the links with a particular class e.g. 'clickable'. As long as the link has that class, it becomes clickable.
I have been tweeking the below script but do not know how to introduce the class comparism, can anyone help me with this?
var links = document.getElementsByTagName('a');
document.addEventListener('click', function (e) {
if (e.target.tag === links.tag) {
e.preventDefault();
document.addEventListener('contextmenu',
event => event.preventDefault());
el_down.innerHTML = "Right click disabled";
}
});