I am trying to implement a content locker on my WP site. I would usually add the HTML code onclick="call_locker()"
on the element that triggers the pop up. However, I do not have direct access to the HTML due to the plugin that I use for building the site.
This is the button element I want to attach the call_locker()
function to:
<a href="#" target="_self" class="fl-button" role="button">
<span class="fl-button-text">Subscribe!</span>
</a>
My intention is to attach the call_locker()
function to the whole .fl-button
class via a .onclick
triggered event. This way I will be able to use it globally on any other .fl-button
or page that I create.
This is the code I came up with:
(function() {
document.getElementsByClassName("fl-button").onclick = function() {
call_locker();
};
})();
However, nothing happens when I click on the button :-(
I am no expert on java so I can only hope my syntax is correct and the terms I used for the post too.
Thanks in advance for your help!