- This topic is empty.
Viewing 8 posts - 1 through 8 (of 8 total)
Viewing 8 posts - 1 through 8 (of 8 total)
- The forum ‘CSS’ is closed to new topics and replies.
The forums ran from 2008-2020 and are now closed and viewable here as an archive.
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.