Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

130
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!