Helllo, i have a Array like this:
let Array1 = [
{name:"try1", id:"id1", symbol:"symbol1"},
{name:"try2", id:"id2", symbol:"symbol2"},
{name:"try3", id:"id3", symbol:"symbol3"},
{name:"try4", id:"id4", symbol:"symbol4"},
{name:"try5", id:"id5", symbol:"symbol5"}
]
and i want to make each of them a button. that i can click on each one. for this, i use .map Funnction ( im not sure this is the best option )
Array1.map(data => $(".check").html(`<a id="${data.id}" class="btn btn-info" href="#" role="button">${data.id}</a>`))
until now i get 5 buttons. 1 button each object with the id of the button.
the problem start here: i trying to catch a Click Event on this buttons. i cant make it done..
I tried:
(`${data.id}`).click(e => console.log("click))
I would be happy for help or any other way with the same result. Thankss !!
(``)what is the selector you used?Event.target, you can check whether a button was clicked and also which button was clicked..forEach..map()is only useful if you assign its outcome to something. (let arr2 = arr.map(...))