Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

180
Visualizações
How do I fix comment showing on code in JavaScript?

I’m trying to download jQuery into my document via my JavaScript file. When I do document.write, however, the "https://" is marked as a comment.

function downloadjQuery() {
    document.open();
    document.write("<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>");
    document.close();
}
about 4 years ago · Juan Pablo Isaza
3 Respostas
Responde à pergunta

0

In your code, you use four same quotes in the string, so JavaScript thinks your string ends there:

"<script src="

I recommend use ' instead of double quotes, or you can use \' or \", also you can use `, some examples:

let Hello = "How 'are' you?"
let World = "How \"you\" did this?"
let Search = 'Searching for \'free mincraft 2022\'...'
let User = `
Hey "there", 'somewhere else'!
`

So try this out:

function downloadjQuery() {
    document.open();
    document.write("<script src='https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js'></script>");
    document.close();
}
about 4 years ago · Juan Pablo Isaza Relatório

0

You're using double quotes and single quotes wrong.

You can try to escape double quotes with \"or use single quotes '.

This line is wrong:

"<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>"

It gets read as "<script src=" https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js "></script>"

about 4 years ago · Juan Pablo Isaza Relatório

0

Your quote use is incorrect. You closed the quotes before the link.

Instead of:

document.write("<script src="link"></script>");

You should do:

document.write("<script src='link'></script>");

When you have to use quotes multiple times, you can also use ' instead of " four times. Also, if you want to keep the raw version of the comment, you can type \ before //.

Example:

(Correct Usage)

\//I printed a raw version of a comment.

(Incorrect Usage)

//I did not print a raw version of a comment.
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda