• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

100
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"};
almost 3 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

almost 3 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 Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error