retrieve `e.target` from jQuery element

Viewed 37

I have a jquery element. The updateHandler function expects a DOM element with e.target.name and e.target.value

How can I pass the e fetched with jQuery to updateHandler function with e.target/e.value?

let e = $('[name="amount"]')
// or
// let e = document.getElementsByName('amount') //

// modify the value of e and pass it to below
updateHandler(e[0]) // This function expects e.target

The error is e.target is undefined. In both cases using jQuery($) or document.xxx.

1 Answers

SOLUTION

As per @Ouroborus hint in above comment. this solved using below coding. Thanks

let e = $('[name="amount"]')
updateHandler({target: {name: 'amount', value: parseFloat(e.val() || 0).toFixed(2)}})
Related