Jump to content

Code examples work, html export to pc doesn't


DJ411
 Share

Recommended Posts

So i've been building up to my first website. I've been using w3schools for css codes and examples. My site is hosted via tumblr is almost complete. I could use what i have as of now. Just needs a more solid/ final theme and some unique features i want. The one biggest feature i want on my page is a hidden div that is activated by some js Function. That code is thankfully provided for me. But here is now my issue and the reason that i'm here, hoping to get an answer or a solution!

 

So the js code i have found is hosted on codepen. The example works perfectly. I can even modify it to my liking and it still works as intended. Here is my problem. When i copy that working code to my HTML file it doesn't work... I even start a new html file, paste everything where it belongs and it still doesn't work! I can even copy the code to http://jsfiddle.net/ & http://jsbin.com/ and those sites even work.

 

What is making the code i'm using not work on my pc & tumblr but works on these example sites. Is there a script src i have to install? i just don't understand why everything i've done has worked but this code.

 

Here is the code i'm trying to import. http://codepen.io/svinkle/pen/iBHGE

Link to comment
Share on other sites

It requires jQuery.

 

To make jQuery work you need to include the jQuery library with a <script> tag.

 

You can either do that or look for code that doesn't need jQuery, because I think including jQuery would be overkill for a tiny task like that.

Link to comment
Share on other sites

It requires jQuery.

 

To make jQuery work you need to include the jQuery library with a <script> tag.

 

You can either do that or look for code that doesn't need jQuery, because I think including jQuery would be overkill for a tiny task like that.

 

i have that already included. that is why i'm posting here.

 

is this the correct one?

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>

Here is another set of code i found that i can't get it to work. http://jsfiddle.net/VLNDL/

Edited by DJ411
Link to comment
Share on other sites

I'm going to need to see your own implementation of the code to determine why it's not working. Check your browser's javascript console to see what errors occur and on what line.

Link to comment
Share on other sites

I'm going to need to see your own implementation of the code to determine why it's not working. Check your browser's javascript console to see what errors occur and on what line.

 

Ok so here is the HTML that i'm testing with for http://jsfiddle.net/VLNDL/ until i get it to work http://pastebin.com/fChMqpYZ . Here is the HTML that i have. Its untouched. All i have done is copy and pasted it from the code to an HTML in a way i need to work with it.

Edited by DJ411
Link to comment
Share on other sites

The problem is that you put the code at the top of the page, before any of the elements are loaded. You can either use .ready() event or put the script at the end of the </body> section,

  • Like 1
Link to comment
Share on other sites

The problem is that you put the code at the top of the page, before any of the elements are loaded. You can either use .ready() event or put the script at the end of the </body> section,

 

AW. That i get! because i'm doing all of this with no little to know HTML knowledge ( in High school i made a site with Flash ) i didn't know that! so for later uses of any code if it doesn't work on my PC check the location and of course if that doesn't work then something else is wrong which i've done in the past and have figured out!

 

Thank you for the help i now have my feature implemented onto my site! I can now continue with other ideas.

Link to comment
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
 Share

×
×
  • Create New...