const main = createTableWithContent(val.join('-'), "one");
const two = createTableWithContent(randInt(), "two");
main.append(two);
// Просто добавить...
const three = createTableWithContent(randInt(), "three");
main.append(three);
<input class="price" oninput="calc()">
<input class="quantity" oninput="calc()">
<div id="result"></div>
function calc(){
const priceInput = document.querySelector('.price');
const quantityInput = document.querySelector('.quantity');
const cost = priceInput.value * quantityInput.value;
document.getElementById('result').innerHTML = cost;
}
class myPlugin {
constructor(element, options) {
this.element = element
this.options = Object.assign({}, {
option1: false,
option2: 600
}, options)
}
testMyEvent(){
if (typeof this.options.onEvent === 'function') {
this.options.onEvent(this.element, 123, this.options /* что угодно */);
}
}
}
const plugin = new myPlugin("#element", {
option1: false,
option2: 600,
onEvent: (element, num, opts) => {
console.log(element, num, opts)
}
});
plugin.testMyEvent();