-2

Here is the HTML head:

<head>
    <link type='text/css' rel='stylesheet' href='style.css'>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
    <script type="text/javascript" href='script.js'></script>
</head>

Here are the contents of the jQuery file:

$(document).ready(function() {

    var $block_number = prompt('How many blocks?');

    function writeBoard() {
        while ($.isNumeric($block_number) === false && $block_number < 150) {
            $block_number = prompt('How many blocks?');
        }
        for (var i = 0; i < $block_number; i++) {
            $('#board').prepend("<div class='block'></div>");
        }
    };

    writeBoard();

    $(".block").on("mouseover", function () {
        $(this).css("background-color", "black");
    });

    $('#redo').on('click', function () {
        $('.block').css('background-color', 'white');
        $block_number = prompt('How many blocks?');
        writeBoard();
    });

});

It doesn't seem to be working when the page is loaded locally as it was on jsfiddle for some reason. Any thoughts?

Fiddle: http://jsfiddle.net/zfiscr/9dutj67b/

Shaunak D
  • 20,588
  • 10
  • 46
  • 79
Zack
  • 661
  • 2
  • 11
  • 27

2 Answers2

1

Your script tag should be as follows :

<script type="text/javascript" src="script.js"></script>

instead of

<script type="text/javascript" href="script.js"></script>

Hope that helps!!!

Satwik Nadkarny
  • 5,086
  • 2
  • 23
  • 41
  • @Zack Happens!! You know, we all go through it!! :) – Satwik Nadkarny Feb 17 '15 at 04:48
  • you could use the comments, the answer is not necessary in this cases. –  Feb 17 '15 at 04:58
  • @MrBearAndBeer While I understand what you're trying to get at, this effectively happens to be the answer to the question asked!! – Satwik Nadkarny Feb 17 '15 at 05:34
  • Does't matter, your answer is stupid and you just did to earn points , as I said before, you should use the comments to help the user as @HomoSapiens did, not create a new answer. –  Feb 17 '15 at 05:39
  • @MrBearAndBeer *"you should use the comments to help the user"*.. And what exact value are you trying to add with your comments, Mr? – Satwik Nadkarny Feb 17 '15 at 05:44
  • @MrBearAndBeer My answer is perfectly valid taking into consideration the scope of the question and I will not respond to your petulance any further. Keep whining all you like!! – Satwik Nadkarny Feb 17 '15 at 05:55
1

Script has src , CSS has href :)

<script type="text/javascript" src='script.js'></script>

is correct.

Why ? Please check Here

Community
  • 1
  • 1
Pratik Joshi
  • 11,485
  • 7
  • 41
  • 73