Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS codepen doesn’t like my js?

  • This topic is empty.
Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #41114
    matt_sanford
    Participant

    Why isn’t codepen using my js? http://codepen.io/MattSanford/pen/LxKea

    #116120
    Watson90
    Member

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

    #116121
    matt_sanford
    Participant

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

    #116141
    JoniGiuro
    Participant

    var displayMain = function()
    {
    document.getElementById(“main”).style.display=”block”;
    alert(‘js is loaded’)
    }();

    #116142
    JoniGiuro
    Participant

    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
    }();

    #116158
    tbwiii
    Participant

    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.

    #116187
    matt_sanford
    Participant

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

    #116225
    tbwiii
    Participant

    @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)
  • The forum ‘CSS’ is closed to new topics and replies.