jeewan
jeewan

Reputation: 1605

javascript/jQuery passing arguments in a method

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

Answers (1)

Adil Shaikh
Adil Shaikh

Reputation: 44740

$table += "<td>" + "<a href='#' onclick='alert("+alertValue+");'>" + items[i].senderID +"</a>" +"------"+ items[i].startTime +"</td>";

Upvotes: 2

Related Questions