0

in my html I have:

<script
src="https://code.jquery.com/jquery-3.3.1.min.js"
integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="
crossorigin="anonymous">
console.log('hello');
</script>

and I get nothing in console, but as soon as I remove all attributes in the script tag:

<script>
console.log('hello');
</script>

I can see the output in console. Yesterday everything worked fine, but today something is wrong.

0

3 Answers 3

1

You can't have both a src and code inside your script

What you should do:

<script
  src="https://code.jquery.com/jquery-3.3.1.min.js"
  integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="
  crossorigin="anonymous">
</script>

<script>
  console.log('hello');
</script>
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for the reply, it works now! Weird, yesterday it seemed like it worked this way, but today it is not.
So....many....duplicates.... :-)
0

In Javascript you can not put code with src file. For that you must have to write separate include javascript file code and other javascript code like below.

Here you can include 3rd party javascript or jquery file like this:

    <script
src="https://code.jquery.com/jquery-3.3.1.min.js"
integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="
crossorigin="anonymous"></script>

And for additional javascript code you can write like this:

<script>
console.log('hello');
</script>

1 Comment

How is your solution different from Carsten's?
0

Actually, Script Not Support Src and Others Code in the one Script tag

The pure javascript Normally Support console.log and alert() not needed for any others library or jquery.

if you try this code here

<script>
  console.log("Hello Console");
</script>

--- Thnk You ----

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.