JavaScript Tutorial For Beginners #40 – The onClick Event




Hey ninjas / ninjarettes, in this JavaScript tutorial I want to run through a detailed example of how we can use the onclick event in JavaScript to create cool functionality on our websites.

In this example I’ll use the onclick event to create a ‘show more’ style content box which expands and shrinks as you click the button.

Any questions, fire away :).

SUBSCRIBE TO CHANNEL – https://www.youtube.com/channel/UCW5YeuERMmlnqo4oq8vwUpg?sub_confirmation=1

========== JavaScript for Beginners Playlist ==========

========== CSS for Beginners Playlist ==========

========== HTML for Beginners Playlist ==========

========== The Net Ninja ============

For more front-end development tutorials & to black-belt your coding skills, head over to – https://www.youtube.com/channel/UCW5YeuERMmlnqo4oq8vwUpg or http://thenetninja.co.uk

========== Social Links ==========

Twitter – @TheNetNinja – https://twitter.com/thenetninjauk

Original source


24 responses to “JavaScript Tutorial For Beginners #40 – The onClick Event”

  1. hi ninja!
    thank you for making these educational videos. These tutorials help me a lot. I did almost the same thing, but I gave my content ''position: fixed''. for some unknown reason, when I click the button, content appears faster than content div… any suggestions?

  2. I implemented the code into my webpage, upon having watched your presentation. Notwithstanding, in spite of the successful realisation of the visual commands, including the substitution of "Show More" for "Show Less" and vice versa, I failed at correctly setting up the code in order to provide for the stainless implementation of it. despite having read multiple threads online, having thoroughly perused. my own programm, being a complete and utter tyro
    myself (it has only been a few months ago, ,that I began to code), I do struggle with the problems resolution.
    here is the link to my programm :
    http://codepen.io/Pukii/pen/jrqPbd
    thank you in advance!

  3. Hi, Ninja,

    I have typed all ur codes, but it shows error " Expect '===' and instead saw '== ', error at " if (content.className == "open") ". Then I change to it "==", but the button is not working. Help? Thanks.

Leave a Reply