I have to modify a website, and since the person that did it left the company (fired) and I’m not a web developer I can’t figure it out how to implement a function.
I have a button declared in this way using jquery(I believe), this piece of code is contained in a function called
var buildCurrentCodesButtons = function (currentArray) {...
var content = 'data-content="<table data-codes>' +
'<tr><td>Added by:</td><td>' + currentArray[i].addby + '</td></tr>' +
'<tr><td>DOS:</td><td>' + currentArray[i].dateofservice + '</td></tr>' +
'</table>' +
'<p code-description ><i>' + currentArray[i].description + '</i>' +
'</p > ' +
'<button class='btn_sx' href='#' id='suspectbtn' + currentArray[i].hashKey + ''>Suspect</button>"';
I need to attach to suspectbtn an onclick, and I can’t successfully do it. this is a button that is create programmatically because is part of a list of buttons, so every button I suppose need to have a different id, and I would like to pass the content of currentArray when the onclick is triggered.
What I’m trying now is this
$('#suspectbtn' + currentArray[i].hashKey).on('click', function () {
console.log("test2");
});
right after I create the var content, so I can use the same id, but nothing I’m trying is working, I also tried to define the function inside the onclick but it get cut at the first ‘, how can I define an onclick on my buttons?
3