Hi, just starting on Jquery and stuck on challenge 99. I’m not sure how to close the script element or what else I need to do to pass this challenge. The instructions:
-
First, add a script element at the top of your page. Be sure to close it on the following line.
-
Inside your script element, add this code: $(document).ready(function() { to your script. Then close it on the following line (still inside your script element) with: });
This is what I have:
<script $(document).ready(function() {
});
Can someone help me with what I’m doing wrong? Thanks!
The $(document).ready(function() { })
part should be in between an opening and closing script tag:
<script>
// Your code here
</script>
1 Like
<script $(document).ready(function() {
});
Like this? I tried that but still says it’s not correct.
<script
$(document).ready(function() {
});
</script>
I meant this sorry. And for some reason everytime I post this it doesn’t show the ending script tag even though I type it.
1 Like
I’ve edited your post for readability. When you enter a code block into the forum, remember to precede it with a line of three backticks and follow it with a line of three backticks to make easier to read. See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>
) will also add backticks around text.
Almost, but you will have to close the opening tag at the first line.
1 Like
remember how you kept all the CSS code between two style tags like so:
<style>
CSS code {
blah : blahBlah;
}
</style>
you are doing the same here for all the JS and jQuery… putting the code between script tags as @BenGitter demonstrated above
Edit: the document.ready stuff is jQuery that waits til the page loads and then executes, so it needs to be between both tags…
a little blurb on: $(document).ready()