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

228
Visualizações
How can I test jQuery code in the browser console?

I want to test if my jQuery code is sound. So I thought I just enter the code in the browser console. I use Mozilla Firefox.

I want to test if I can select ids and that stuff.

But when I enter:

$("#testId")

I get the following error:

Uncaught SyntaxError: private names aren't valid in this context

Are the elements that I want to access private? What does that mean and why is that?

about 4 years ago · Juan Pablo Isaza
3 Respostas
Responde à pergunta

0

Try something like this

<div id="testId">hi user1664377</div>

then

console.log($("#testId").text()); // you will see "hi user1664377" in console
about 4 years ago · Juan Pablo Isaza Relatório

0

In case you dont have access to jQuery in console (window/document).

You can add the jQuery script to DOM directly from console by creating and appending the script to body:

let s = document.createElement('script')
s.setAttribute('src','https://code.jquery.com/jquery-3.6.0.min.js')
document.getElementsByTagName('body')[0].appendChild(s)

And now eg get the jQuery version:

console.log(jQuery.fn.jquery)
about 4 years ago · Juan Pablo Isaza Relatório

0

follow these steps to test & practice JQuery in your console: first, use the browser debugger tool to inspect any element in your browser, view the source code, e.g like classNames and id'

Next, now use the jQuery syntax to select it example $(".className") or $("#ids"),

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