function show(x){
console.log(x)
}
users.forEach(item => {
let content = document.createElement("div")
content.classList.add("content")
content.innerHTML = `
<input type="button" id='add_deposit' value="add" onclick="show(${item})" /
`;
list.append(content)
it outputs identifier not found. how do i pass corrosponding item inside button onclick function
Use addEventListener so that the click handler can see the item in its closure. Inline handlers can only reference global variables, which doesn't work well inside a loop (or, at all, often) - best to avoid them whenever possible.
You also shouldn't use the add_deposit ID - there should only be at most one element with a particular ID in a document.
users.forEach(item => {
const content = document.createElement("div")
content.classList.add("content")
content.innerHTML = `
<input type="button" value="add" />
`;
content.children[0].addEventListener('click', () => {
show(item);
});
list.append(content)
});