Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
Ryan Leenox

Which browser do i have to use?

Recommended Posts

Hi guys, today morning i was reading the "get started page" on the GSAP web site, i was finding it really interesting, then i decided to try it. But as soon as i wrote my code and launched on google chrome, it didn't seem to work at all. Then i started wondering if there were some problems with my browser even because i tried the same code on CODEPEN () and it's working perfectly. So my question is, what to i have to do, to run the code on my browser? 

ps. I'm new here, this is my first post and i really hope this is the right section, these are the right topic tags, if not i'm really sorry about it.post-36694-0-24071200-1433283208_thumb.png

See the Pen EjWNRg by RyanLeenox (@RyanLeenox) on CodePen

Link to post
Share on other sites

Hi Ryan Leenox  :)

 

try this :

document.addEventListener('DOMContentLoaded', function() {
//your script here
});

or with jquery :

$( document ).ready(function() {
//your script here
});
  • Like 4
Link to post
Share on other sites

The reason your code works on CodePen is because the JavaScript is placed right before the closing </body> tag, so the #tester element has already been created by the time your code executes. When you place your JavaScript in the <head> like that, the element doesn't exist yet, so your code isn't able to find #tester. If you're going to keep your JavaScript in the <head>, you're going to have to use one of the solutions Diaco shared.

 

Location matters...

See the Pen xGqgqY?editors=100 by osublake (@osublake) on CodePen

  • Like 2
Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×