Change Text with Click Events on local pc

Tell us what’s happening:
My code is not running locally. I was trying to built the random quote generator but the code was not working ,so i decided to step back and try the show message code, which is also not working. My git link:https://github.com/karan919/Random-Quote-Generator

Can someone please check the git and tell me why the code not running .
Your browser information:

Your Browser User Agent is: Mozilla/5.0 (Windows NT 6.2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36.

Link to the challenge:
https://www.freecodecamp.org/challenges/change-text-with-click-events

So, there are a couple of problems here.

1 Because your javascript file needs jQuery, that must be loaded before your javascript file: line 8 and 9 of your html file need to be switched. There was a console error screaming about this. Learn to read your console, CTRL-SHFT-J or something similar.

2 There is no div element with an id called “demo” so your statement:

 $("#demo").html("Here is the message");

has nothing to target. Add the line:

<div id="demo"></div>

in your HTML wherever you want that to go.

3 OK, this isn’t the end of the world, but you’ve chosen some rather unfortunate names for your javascript files, javascript.js and jsx.js. The first is redundant and the second, well there is hybrid language in React called jsx. Usual names for a javascript file are index.js, main.js, or if you have more than one js file, something more descriptive.

1 Like

Thanks man for the solution. I didn’t know that you need to load jQuery first and also thanks for the naming tips.