小编Jes*_*ler的帖子

将变量发送到JQuery函数

我是jQuery的新手,但我希望有人能够帮助我.我搜索了这个论坛(和其他人),但一直找不到我能做的答案.

我有这样的链接:

<a href="#">
Run Code Online (Sandbox Code Playgroud)

和一个jQuery脚本:

$("div.show_dialogbox").click(function(){
    $("div#dialogboxwraper").animate({
        height: "400px"
    }, "slow")
    .animate({
        height: "200px"
    }, "slow");
});
Run Code Online (Sandbox Code Playgroud)

我希望能够发送一个带有链接的变量,并在脚本中使用它,如下所示:

<a href="#" OnClick="variable(200)">


$("div.show_dialogbox").click(function(variable){
    $("div#dialogboxwraper").animate({
        height: variable+200+"px"
    }, "slow")
    .animate({
        height: variable+"px"
    }, "slow");
});
Run Code Online (Sandbox Code Playgroud)

jquery

3
推荐指数
1
解决办法
220
查看次数

标签 统计

jquery ×1