Javascript / JQuery с предупреждением, когда загрузка страниц не работает - PullRequest
0 голосов
/ 25 февраля 2019

Я пытаюсь получить предупреждение при загрузке моей веб-страницы.Код Javascript работает, когда он встроен в код HTML, но когда он помещен в отдельный файл и связан / сохранен как script.js, ничего не происходит.Может ли кто-нибудь случайно увидеть, что я делаю не так?Вот код, если вы случайно увидите, в чем я виноват, я был бы очень признателен.

$(document).ready(function() {
      alert("Welcome!);
      });
background-color:Teal;

}
h1 {
  text-align: center;
  color: Gold;
  font-family: arial;
  font-size: 25pt;
}
#p1 {
  text-align: left;
  color: white;
  font-family: arial;
  font-size: 14pt;
  margin-top: 40px;
  margin-bottom: 20px;
  margin-left: 10px;
  margin-right: 300px;
}
#p2 {
  text-align: right;
  color: white;
  font-family: arial;
  font-size: 14pt;
  margin-top: 100px;
  margin-bottom: 20px;
  margin-left: 300px;
  margin-right: 10px;
}
#p3 {
  text-align: left;
  color: white;
  font-family: arial;
  font-size: 14pt;
  margin-top: 100px;
  margin-bottom: 20px;
  margin-left: 10px;
  margin-right: 300px;
}
#img1 {
  float: left;
  padding-right: 15px;
  width: 200px;
}
#img2 {
  float: right;
  padding-left: 15px;
  width: 200px;
}
a:link {
  color: gold;
  background-color: transparent;
  font-family: arial;
  text-decoration: none;
}
a:visited {
  color: gold;
  background-color: transparent;
  font-family: arial;
  text-decoration: none;
}
a:hover {
  color: white;
  background-color: transparent;
  font-family: arial;
  text-decoration: underline;
}
a:active {
  color: lime;
  background-color: transparent;
  font-family: arial;
  text-decoration: underline;
}
<!DOCTYPE html>
<html>

<head>
  <title>
    "Cute Cats"
  </title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
  <script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
  <link rel="stylesheet" type="text/css" href="styles.css">
</head>

<body>
  <script src="script.js">
  </script>
  <h1> Cute Cats </h1>


  <p id="p1"> <img src="Tulip.jpg" alt="Cute Cat-Tulip" id="img1"> Find box a little too small and curl up with fur hanging out lick arm hair or sweet beast swat at dog, and chirp at birds that box? i can fit in that box. Spit up on light gray carpet instead of adjacent
    linoleum. Spill litter box, scratch at owner, destroy all furniture, especially couch find empty spot in cupboard and sleep all day, licks paws ptracy,intently sniff hand, or really likes hummus weigh eight pounds but take up a full-size bed. Chew
    the plant. Bleghbleghvomit my furball really tie the room together hiss and stare at nothing then run suddenly away and warm up laptop with butt lick butt fart rainbows until owner yells pee in litter box hiss at cats stretch, ooh, are those your
    $250 dollar sandals?

  </p>


  <p id="p2"> <img src="Tikki.jpg" alt="Cute Cat-Tikki" id="img2"> Slap kitten brother with paw spread kitty litter all over house, i could pee on this if i had the energy purr when being pet for nya nya nyan. Touch water with paw then recoil in horror eat all the
    power cords for chill on the couch table, annoy the old grumpy cat, start a fight and then retreat to wash when i lose so scratch me there, elevator butt refuse to come home when humans are going to bed; stay out all night then yowl like i am dying
    at 4am. Eat the rubberband the cat was chasing the mouse so demand to be let outside at once, and expect owner to wait for me as i think about it yet taco cat backwards spells taco cat furrier and even more furrier hairball for groom forever, stretch
    tongue and leave it slightly out, blep stand in front of the computer screen. Red light attracts my eyes, light must die, attack!

  </p>


  <p id="p3"> <img src="Maddi.jpg" alt="Cute Cat-Maddison" id="img1"> More napping, more napping all the napping is exhausting. Fish i must find my red catnip fishy fish who's the baby pet me pet me don't pet me scratch need to chase tail, but intently stare at the
    same spot, or i like frogs and 0 gravity. Meow to be let out thinking longingly about tuna brine or catasstrophe scratch, yet stare at wall turn and meow stare at wall some more meow again continue staring take a big fluffing crap cough hairball on
    conveniently placed pants. Lounge in doorway hiding behind the couch until lured out by a feathery toy. Sit on human give attitude, or meow go back to sleep owner brings food and water tries to pet on head, so scratch get sprayed by water because
    bad cat or lick butt. Stare at ceiling.

  </p>

</body>

Опять-таки, мы очень ценим любое понимание.

1 Ответ

0 голосов
/ 25 февраля 2019

Вы пропустили конец двойных кавычек в вашем предупреждении.Я исправил это для вас во фрагменте ниже.

Примечание: Это избыточно , чтобы включить jQuery дважды , поэтому удалите это.(Если причина, по которой вы включили jQuery дважды, заключалась в том, что он запрашивает вас во фрагменте кода, вам не нужно делать это, если вы уже включили его откуда-то еще).

$(document).ready(function() {
  alert("Welcome!");
});
background-color:Teal;

}
h1 {
  text-align: center;
  color: Gold;
  font-family: arial;
  font-size: 25pt;
}
#p1 {
  text-align: left;
  color: white;
  font-family: arial;
  font-size: 14pt;
  margin-top: 40px;
  margin-bottom: 20px;
  margin-left: 10px;
  margin-right: 300px;
}
#p2 {
  text-align: right;
  color: white;
  font-family: arial;
  font-size: 14pt;
  margin-top: 100px;
  margin-bottom: 20px;
  margin-left: 300px;
  margin-right: 10px;
}
#p3 {
  text-align: left;
  color: white;
  font-family: arial;
  font-size: 14pt;
  margin-top: 100px;
  margin-bottom: 20px;
  margin-left: 10px;
  margin-right: 300px;
}
#img1 {
  float: left;
  padding-right: 15px;
  width: 200px;
}
#img2 {
  float: right;
  padding-left: 15px;
  width: 200px;
}
a:link {
  color: gold;
  background-color: transparent;
  font-family: arial;
  text-decoration: none;
}
a:visited {
  color: gold;
  background-color: transparent;
  font-family: arial;
  text-decoration: none;
}
a:hover {
  color: white;
  background-color: transparent;
  font-family: arial;
  text-decoration: underline;
}
a:active {
  color: lime;
  background-color: transparent;
  font-family: arial;
  text-decoration: underline;
}
<!DOCTYPE html>
<html>

<head>
  <title>
    "Cute Cats"
  </title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
  <link rel="stylesheet" type="text/css" href="styles.css">
</head>

<body>
  <script src="script.js">
  </script>
  <h1> Cute Cats </h1>


  <p id="p1"> <img src="Tulip.jpg" alt="Cute Cat-Tulip" id="img1"> Find box a little too small and curl up with fur hanging out lick arm hair or sweet beast swat at dog, and chirp at birds that box? i can fit in that box. Spit up on light gray carpet instead of adjacent
    linoleum. Spill litter box, scratch at owner, destroy all furniture, especially couch find empty spot in cupboard and sleep all day, licks paws ptracy,intently sniff hand, or really likes hummus weigh eight pounds but take up a full-size bed. Chew
    the plant. Bleghbleghvomit my furball really tie the room together hiss and stare at nothing then run suddenly away and warm up laptop with butt lick butt fart rainbows until owner yells pee in litter box hiss at cats stretch, ooh, are those your
    $250 dollar sandals?

  </p>


  <p id="p2"> <img src="Tikki.jpg" alt="Cute Cat-Tikki" id="img2"> Slap kitten brother with paw spread kitty litter all over house, i could pee on this if i had the energy purr when being pet for nya nya nyan. Touch water with paw then recoil in horror eat all the
    power cords for chill on the couch table, annoy the old grumpy cat, start a fight and then retreat to wash when i lose so scratch me there, elevator butt refuse to come home when humans are going to bed; stay out all night then yowl like i am dying
    at 4am. Eat the rubberband the cat was chasing the mouse so demand to be let outside at once, and expect owner to wait for me as i think about it yet taco cat backwards spells taco cat furrier and even more furrier hairball for groom forever, stretch
    tongue and leave it slightly out, blep stand in front of the computer screen. Red light attracts my eyes, light must die, attack!

  </p>


  <p id="p3"> <img src="Maddi.jpg" alt="Cute Cat-Maddison" id="img1"> More napping, more napping all the napping is exhausting. Fish i must find my red catnip fishy fish who's the baby pet me pet me don't pet me scratch need to chase tail, but intently stare at the
    same spot, or i like frogs and 0 gravity. Meow to be let out thinking longingly about tuna brine or catasstrophe scratch, yet stare at wall turn and meow stare at wall some more meow again continue staring take a big fluffing crap cough hairball on
    conveniently placed pants. Lounge in doorway hiding behind the couch until lured out by a feathery toy. Sit on human give attitude, or meow go back to sleep owner brings food and water tries to pet on head, so scratch get sprayed by water because
    bad cat or lick butt. Stare at ceiling.

  </p>

</body>
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...