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

131
Visualizações
How to send data to custom element setter method by Jquery?

I want to know, how to send data to a custom element by jquery. it is possible?.

I have a javascript vanilla code example over here, for understanding my question :

// My custom element class
class MyCustomElementExample extends HTMLElement {
  set customData(data) {
    this._data = data;
    this.render();
  }

  render() {
    this.innerHTML = `<h1>${this._data.name}</h1>`;
  }
}

customElements.define('my-custom-element-example', MyCustomElementExample);

// select my custom element and send data to'customData'(setter method)
document.querySelector('my-custom-element-example').customData = {
  name: "DERI KURNIAWAN"
};
<body>
  <my-custom-element-example></my-custom-element-example>
</body>

This is my specific javascript vanilla code for sending data to setter method :

document.querySelector('my-custom-element-example').customData = {name: "DERI KURNIAWAN"};

So is there a way to do that? or is there a special way? maybe if I think of the code like this:

$('my-custom-element-example').customData = {name: "DERI KURNIAWAN"};
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

document.querySelector('my-custom-element-example')

and

$('my-custom-element-example')

Do exactly the same: retrieve a reference to a DOM element

But the jQuery version requires loading a 50KB+ library

jQuery was great in the age when all Browsers behaved different.

.querySelector and .querySelectorAll are the JavaScript standards;

IE9 was the last browser to implement these standards... in 2011

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