0

I am a beginner with this so it may be basic. I have included all the files, and try to add a button. I see the button but when clicked I get this error:

Uncaught ReferenceError: $ is not defined

the code :

 <head>
            <meta name = "viewport" content="width=device-width, initial-sclase=1">
            <title>Create</title>
            <link rel="stylesheet" type="text/css" href="Stylesheets/main.css"/>
            <link rel="stylesheet"  href="Bootstrap/css/bootstrap.min.css"/>
 </head>




  <body>


        <button class="btn btn-success" onclick="$(this).hide();">Clickit</button>


    <! --- scripsts                                                  
    <! --- bootstrap js files
     <script src="Bootstrap/js/jquery.min.js"></script>
     <script src="Bootstrap/js/bootstrap.min.js"></script>
    <! --- my java script file
     <script src="javascripts/main.js"></script>

    </body>

Assuming this is all my code, I also get some other errors on consule like :

util.js:56 Uncaught TypeError: Cannot read property 'fn' of undefined
    at util.js:56
    at util.js:10
    at bootstrap.min.js:6
    at bootstrap.min.js:6

//and this one

Failed to load resource: the server responded with a status of favicon.ico:1

EDIT :

My project has folders structure: Bootstrap->js-> inside jquery.min.js and bootstrap.min.js, all under 1 folder which is my project.

Curnelious
  • 1
  • 16
  • 76
  • 150
  • The first error you have listed, refer to [this answer on StackOverflow](https://stackoverflow.com/questions/10779148/javascript-jquery-is-not-defined-function-error) for your issue. – Irby Dec 11 '18 at 03:30
  • What version of bootstrap you are trying to use? For **Bootstrap 3** first try a page with the [started template](https://getbootstrap.com/docs/3.3/getting-started/#template) using CDN libraries and then proceed to download and use they locally. Same is valid for **Bootstrap 4** with this [started template](https://getbootstrap.com/docs/4.0/getting-started/introduction/#starter-template). – Shidersz Dec 11 '18 at 03:33
  • I downloaded all of them today so the latest versions. – Curnelious Dec 11 '18 at 03:44
  • @Irby not sure its the answer because as you see I already included the files as you may see. (?) – Curnelious Dec 11 '18 at 03:49
  • Please see edits.\ – Curnelious Dec 11 '18 at 04:02
  • Have you try view page score and try click your link bootstrap?? If didnt show anything, so you need change your url. – Wolfzmus Dec 11 '18 at 04:09

2 Answers2

2

To get bootstrap, go to http://getbootstrap.com/docs/4.1/getting-started/download/. There it tells you what you need to use bootstrap.

<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>

You can also go to http://getbootstrap.com/docs/4.1/getting-started/introduction/ to get the html tags to put in bootstrap.

I think that's probably the problem. Try with those.

Edit:

<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<body>
  <button class="btn btn-success" onclick="$(this).hide();">Clickit</button>
</body>

I'm assuming you wanted that?

Aniket G
  • 3,471
  • 1
  • 13
  • 39
0

Well I guess it is too basic so some of you didn't see, my comment was wrong, it should be closed :

 <!-- jquery files -->

Now it works.

Curnelious
  • 1
  • 16
  • 76
  • 150