【问题标题】:javascript/jQuery passing arguments in a methodjavascript/jQuery 在方法中传递参数
【发布时间】:2013-06-03 00:17:35
【问题描述】:

如何在这段代码中传递参数

$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
}

你能帮我写一个这样的警报吗:

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
}

【问题讨论】:

    标签: javascript jquery methods arguments


    【解决方案1】:
    $table += "<td>" + "<a href='#' onclick='alert("+alertValue+");'>" + items[i].senderID +"</a>" +"------"+ items[i].startTime +"</td>";
    

    【讨论】:

    • 非常感谢,总是卡在引号和双引号中... aaagghhh ...无论如何,非常感谢您
    • 我稍后会接受你的回答,SOF 不允许我现在接受你的回答,8 分钟后说 :-)
    猜你喜欢
    • 1970-01-01
    • 2013-08-01
    • 2014-10-25
    • 1970-01-01
    • 2017-12-22
    • 1970-01-01
    • 2011-04-16
    • 2014-10-18
    • 1970-01-01
    相关资源
    最近更新 更多