Reputation: 1605
How can I pass argument in this code
$table += "<td>" + "<a href='#' onclick='myFunction(HERE_I_need_to_pass_an_argument);'>" + items[i].senderID +"</a>" +"------"+ items[i].startTime +"</td>";
function myFunction (myVariable) {
// my other logic goes here
}
can you help me writing an alert on that like this:
alertValue = 10;
$table += "<td>" + "<a href='#' onclick='alert(alertValue );'>" + items[i].senderID +"</a>" +"------"+ items[i].startTime +"</td>";
function myFunction (myVariable) {
// my other logic goes here
}
Upvotes: 0
Views: 37
Reputation: 44740
$table += "<td>" + "<a href='#' onclick='alert("+alertValue+");'>" + items[i].senderID +"</a>" +"------"+ items[i].startTime +"</td>";
Upvotes: 2