Treehouse: Grow your CSS skills. Land your dream job.

codepen doesn’t like my js?

  • # December 2, 2012 at 6:23 pm

    Why isn’t codepen using my js?

    # December 2, 2012 at 7:15 pm

    You haven’t selected a library when you click the cog at the top-right of the JavaScript box? Is this right?

    # December 2, 2012 at 7:38 pm

    I tried selecting a library but it didn’t affect anything.

    # December 3, 2012 at 4:07 am

    var displayMain = function()
    alert(‘js is loaded’)

    # December 3, 2012 at 4:08 am

    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

    # December 3, 2012 at 9:05 am

    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 () {



    That got it working for me.

    # December 3, 2012 at 4:39 pm

    @tbwii Thanks! is this just a codepen issue? Because it works just fine on my development page, prior to your solution.

    # December 3, 2012 at 9:10 pm

    @matt_sanford I think it might be an iframe issue – I have had similar things happen with jsFiddle. Chris could say for sure though.

Viewing 8 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic.