0

So here is the issue: I began coding html with no prior knowledge, so unfortunately I did not create .css or .js files to begin with. Decently far along with the website I'm working on I tried to take all my styling information and js code to put in their respective files whilst deleting what was in the original html. Upon much review I cannot find the issue. They both should be linked correctly as everything is in the same directory and I put some js code to prove that the jquery file from my 'external' file was not loaded.

Here is my js file, css, and heading of my html.

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
hr { 
margin: 1px; 
}

body {
    background:  url("Brown Background 2 adjusted.jpg") no-repeat ;
    background-attachment: fixed;
    background-position: ;
    background-size: cover;

}
html{
  margin:0;
  padding:0;
}


body,h1, p 
.mainfont{
  font-family: "Helvetica Neue", "Segoe UI", Segoe, Helvetica, Arial, "Lucida Grande", sans-serif;
  font-weight: normal;
  margin: 0px;
  padding: 0px;
  text-align: center;
        }


@font-face {
    font-family: 'myFirstFont';
    src: url('melmacracked.woff') format('woff');
}
#titleheader
{
color:#6b4527;
font-size: 48px;
font-family: 'myFirstFont';
}

img{
width: 50%;
}




h1 {
  font-size: 48px;
  font-weight: 300;
  margin: 0 0 0px 0;
}

.lead {
  font-size: 21px;
  font-weight: 200;
  margin-bottom: 0px;
}

p {
  margin: 0 0 0px;
}
.margin{
margin:30px;
}
<!DOCTYPE html>
<html>
<head>
 <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<link rel="stylesheet" href="fishook-theme.css" type="text/css" />
<script type="text/javascript" src="external.js"></script>
<script>if (typeof jQuery != 'undefined') {

    alert("jQuery library is loaded!");

}else{

    alert("jQuery library is not found!");

}</script>
</head>

FYI I have read numerous other posts with the same vague problem but no solutions to fix mine. Thanks in advance.

  • Just to clarify, the contents of your "external.js" file are the ` – James Thorpe Oct 09 '15 at 21:14
  • 2
    You don't put ` – Barmar Oct 09 '15 at 21:16
  • Also be aware of putting script tags on your head element, it could very well be the root of your issues, or lead to them in the future: http://stackoverflow.com/questions/436411/where-is-the-best-place-to-put-script-tags-in-html-markup – AGE Oct 09 '15 at 21:22
  • Yes James you are correct, that was my externa js file with the script tag. Thanks all for the help. – John Woods Oct 10 '15 at 23:11

1 Answers1

0

So, if I understand it correctly, the first snippet is inside your js file?

Well, that is the problem. It should be inside your html file. The js file does not understand the html snippet. It doesn't know what to do with it.

<!DOCTYPE html>
<html>
<head>
  <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
  <link rel="stylesheet" href="fishook-theme.css" type="text/css" />
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js">  </script>
  <script>if (typeof jQuery != 'undefined') {

    alert("jQuery library is loaded!");

  } else {

    alert("jQuery library is not found!");

  } </script>
</head>
ngstschr
  • 2,119
  • 2
  • 22
  • 38