jQuery outside of codecademy

jquery

#1

I'm trying to get a "real-world" feel web development by attempting some projects of my own in my own editor. I can link HTML, CSS, and JS just fine, however I can't duplicate a basic fading box using jQuery outside of Codecademy.

I've created a .js file inside my web project, even cut and pasted code directly from Codecademy sessions. What am I missing?


#2

Hi Dave,

In your index.html file, you're probably linking to jQuery like this:

<script src="//some-url.com/directory/jquery.min.js"></script

You'll need to change // to http(s)://, like this:

<script src="http://some-url.com/directory/jquery.min.js"><script>

If that's not the problem, would you mind posting the code you've got in each file?


#3

HTML

      <link rel='stylesheet' type='text/css' href='C:\Users\user\workspace\myJSProject\WebContent\First style.css'/>
        <script type='text/javascript' src='C:\Users\user\workspace\myJSProject\WebContent\MyJs.js'></script>
    </head>
    <body>
        <div class="vanish"></div>
        <div class="vanish"></div>
        <div class="vanish"></div>
        <div class="vanish"></div>
        <br/><button>Click Me!</button>
    </body>
</html>

CSS
.vanish {
height: 100px;
width: 100px;
display: inline-block;
background-color: #F38630;
border-radius: 5px;
}
JS
$(document).ready(function() {
$('button').click(function() {
$('.vanish').fadeOut('slow')
});
});


#4

OK Dave, you're missing a link to jQuery. Add this right before your current <script> tag:

<script src="https://code.jquery.com/jquery-latest.min.js"></script>

#5

Thanks!
I knew the jQuery was a javascript, but the training sessions here didn't make it clear on how jQuery operates.

Thanks for helping clarify.


#6

No problem, glad I could help :)
Feel free to ask in the forums if you need help with your code later on!


#7

Very helpful - thank you. I had the same issue and your script made it work for me.


#8

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.