Code from freecodecamp not working in codepen. Why?

Code from freecodecamp not working in codepen. Why?
0

#1

Hi,
I’m trying to run simple peace of code form camp in codepen and its not working and I have no idea why.

code from > Change Text with Click Events (263)

http://codepen.io/pietruha8/pen/ZBwMBY?editors=1010


#2

Do you have a link to your pen?

What url did you provide for the request?


#3

http://codepen.io/pietruha8/pen/ZBwMBY?editors=1010


#4

Hi,

Go to Settings > Javascript > add jQuery.

Instead of having your javascript between <script> tags, you can just past the code in the Javascript panel.


#5

uff, thank you. Now I will try to understand why :blush:


#6

Why what? The function you wrote to change the html is a jQuery code (you can see that because of the $ sign). So it requires the jQuery library to work. The same way that your bootstrap classes won’t work if you don’t link your pen to Bootstrap. :relaxed:


#7

ok, thank you. too long brake in course…


#8

Ok thanks that is useful. (I wish they’d explained that in the course manual!)

My code seems to be refreshing immediately after I click the button. Currently here in the code. Any idea how to prevent this?


#9

Hmmm! I’m sure loads of folks have encountered this problem:

When I copy and paste HTML and CSS from FreeCodeCamp into CodePen it doesn’t work. Sometimes nothing appears in the preview window, at best, it appears incorrectly and doesn’t function as it does on the FCC challenges.

Here’s a link to one of mine: https://codepen.io/Fishbite/pen/JmLvWe

Could someone please tell me why and how to correct this please?

Thanks in advance :slight_smile:


#10

Remove the tags from the CSS sheet. You only need those in your HTML files, not in the CSS files :slight_smile:


#11

I mean these <style> tags.


#12

That’s simply awesome! Thank you so much @nielsbom