1

Without any script tags, the HTML and CSS work fine. After I add the script and I load the page nothing appears.

<!DOCTYPE html>
<html>
    <head>
        <title>E-Chef: Homepage</title>
        <script type="text/javascript" src="jquery-1.5.2.min.js"/>
        <link rel="stylesheet" type="text/css" href="/Users/stephenhjb/Desktop/Html:Css:JQuery/E-Chef/Stylesheets/E-Chef.css"/>
    </head>
    <body>
        <div class=border>
        <h1 class="header big">E-Chef: All your recipes in one place. Online.</h1>
        </div>
        <script type="text/javascript">
            $(document).ready(function(){ 
            $('div').animate({'fontSize+=36'}, 2000, 'linear');
            });
        </script>
    </body>
</html>

Here is the E-Chef.css file:

.header {
    font-family: Times New Roman;
    color: #5F9EA0;
    text-align: center;
    background-color: #FF7F50;
    border: 30px dotted #FAEBD7;
    margin: 0 0 0 0;
}
.big {
    font-size: 36px;
}
.border {
    border: 5px solid black;
}
3
  • Try put this script on bottom of the code. Commented Oct 3, 2014 at 22:45
  • <div class=border>? <div class='border'> Commented Oct 3, 2014 at 22:47
  • @PHPglue Um… that was a copy/paste error… Commented Oct 3, 2014 at 22:49

1 Answer 1

3

You missed to close the first script tag.

Do it like this:

<script type="text/javascript" src="jquery-1.5.2.min.js"></script>

EDIT: more exactly, script tags are not self-closing, meaning they cannot be used like <script..... /> alone. More on this can be read here: https://stackoverflow.com/a/69984/2037924

EDIT #2: to answer the 2nd part of your question: you'll have to exclude the option of fontSize from the quotes (') in the animate function. Also you're using the incorrect selector, it's actually the font size of the h1 element that you want to increase, not the div's, so change it like this:

$('h1').animate({ fontSize: '+=36'}, 2000, 'linear');

Source: http://api.jquery.com/animate/

Here is a demo: http://jsfiddle.net/y0xkz4un/1/

Sign up to request clarification or add additional context in comments.

6 Comments

Thanks, that was the problem, but my JQuery still doesn’t work. What should I do? Tell me if you want to see my JQuery-1.5.2.js
if this answers your question, accept it as the correct one (big gray check mark), if you have another question, post it as new, someone will answer it, i'm sure (i need to go to bed now :)
Are you hosting jQuery locally or are you pulling it from a CDN?
well, i'll appreciate if you'll do it after 8 minutes, if you'll still be here ;)
@James think you meant to ask this on the original question, not in this answer, right?
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.