the following code is not working:
return targets
.map(
(target, i) => `
<tr>
<td>${target.name}</td>
<td>${target.coordinates.join(':')}</td>
<td>${new Date(target.lastscan).toLocaleString()}</td>
<td>
${$('<button class="icon_nf icon_espionage" type="submit"></button>)').on('click', () => console.log('Test')).html()}
</td>
</tr>
`
)
.join('');
With the html()
function at the end the button element will not be rendered.
When i wrap the button into another element the button will be rendered, but the onclick function is not working.
This code comes from my chrome extension i try to create.
Do you know how i can render a button with onclick without adding a event listenes after i added the button to the dom?