I've read a lot of similar questions and tried implementing the solutions, but none of them works for me.
This is my code within the page:
<button id="hello" type="button">Try it</button>
And this is the script in the header:
$('#hello').click(hello);
function hello(){
alert('inside hello function');
};
The only way I could get this exact code to work was when I put the function call directly into the button, like this:
<button id="hello" type="button" onclick="hello();">Try it</button>
But the problem with this is that Wordpress strips that as soon as I switch to the visual page editor.
Any help would be appreciated!