Why isn't codepen using my js? http://codepen.io/MattSanford/pen/LxKea
You haven't selected a library when you click the cog at the top-right of the JavaScript box? Is this right?
I tried selecting a library but it didn't affect anything.
var displayMain = function() { document.getElementById("main").style.display="block"; alert('js is loaded') }();
you need to add "()" at the end of the function if you want to run it whenever the browser sees it.
function funcitonName(){ //do your magic here }();
He doesn't want it to run on load, he wants it to run on click.
If you want to call the function from the HTML you need to store it as a variable, like so:
displayMain = function () { document.getElementById("main").style.display="block"; }
That got it working for me.
@tbwii Thanks! is this just a codepen issue? Because it works just fine on my development page, prior to your solution.
@matt_sanford I think it might be an iframe issue - I have had similar things happen with jsFiddle. Chris could say for sure though.
Why isn't codepen using my js? http://codepen.io/MattSanford/pen/LxKea
You haven't selected a library when you click the cog at the top-right of the JavaScript box? Is this right?
I tried selecting a library but it didn't affect anything.
var displayMain = function() { document.getElementById("main").style.display="block"; alert('js is loaded') }();
you need to add "()" at the end of the function if you want to run it whenever the browser sees it.
function funcitonName(){ //do your magic here }();
He doesn't want it to run on load, he wants it to run on click.
If you want to call the function from the HTML you need to store it as a variable, like so:
That got it working for me.
@tbwii Thanks! is this just a codepen issue? Because it works just fine on my development page, prior to your solution.
@matt_sanford I think it might be an iframe issue - I have had similar things happen with jsFiddle. Chris could say for sure though.