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

164
Visualizações
Create $(<div/>) Jquery into pure Javascript

I'm trying to create this Jquery code into pure javascript

let container = $('body');

let cursor = $('<div/>').addClass('cursor').html('<svg/></svg>').appendTo(container);

But I got confused when creating a pure javascript selector for this type of selection method from jquery

$('<div/>')

When i try to console $('<div/>') then the output

w.fn.init [div]
 0: div
  length: 1
 [[Prototype]]: Object(0)

Could someone help me to create this jquery code into pure js code

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

0

// Cache the container
const container = document.querySelector('body');

// Create a new element
const cursor = document.createElement('div');

// Add the className, and innerHTML
cursor.className = 'cursor';
cursor.innerHTML = '<svg></svg>';

// Append it to the container
container.appendChild(cursor);
.cursor { border: 1px solid black; height: 100px; width: 100px; }

Additional documentation

  • querySelector

  • createElement

  • className

  • innerHTML

  • appendChild

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