【问题标题】:Feed in variable to jquery将变量输入到 jquery
【发布时间】:2011-04-23 22:40:48
【问题描述】:

您好,我想使用以下功能

$('#add-regular').click(function(){
        $.gritter.add({
            // (string | mandatory) the heading of the notification
            title: 'This is a regular notice!',
            // (string | mandatory) the text inside the notification
            text: 'This will fade out after a certain amount of time. Vivamus eget tincidunt velit. Cum sociis natoque penatibus et <a href="#" style="color:#ccc">magnis dis parturient</a> montes, nascetur ridiculus mus.',
            // (string | optional) the image to display on the left
            image: 'http://a0.twimg.com/profile_images/59268975/jquery_avatar_bigger.png',
            // (bool | optional) if you want it to fade out on its own or just sit there
            sticky: false,
            // (int | optional) the time you want it to be alive for before fading out
            time: ''
        });

        return false;

    });`

图像变量是动态的,我如何更改它,我正在使用 asp.net,我还希望在单击按钮时调用 javascript 函数,请告诉我如何执行此操作。谢谢

【问题讨论】:

  • 那个价值观可以有形象吗?每个变体都有几个按钮,或者它是动态的?
  • 我想在后面的代码中更改“image: 'a0.twimg.com/profile_images/59268975/…”这一行中的值。

标签: jquery asp.net jquery-plugins


【解决方案1】:

试试这个:

平均售价:

<input id="imageValue" value="<%=value%>" type="hidden" />

JS

$('#add-regular').click(function(){
        $.gritter.add({
            // (string | mandatory) the heading of the notification
            title: 'This is a regular notice!',
            // (string | mandatory) the text inside the notification
            text: 'This will fade out after a certain amount of time. Vivamus eget tincidunt velit. Cum sociis natoque penatibus et <a href="#" style="color:#ccc">magnis dis parturient</a> montes, nascetur ridiculus mus.',
            // (string | optional) the image to display on the left
            image: $("#imageValue").val(),
            // (bool | optional) if you want it to fade out on its own or just sit there
            sticky: false,
            // (int | optional) the time you want it to be alive for before fading out
            time: ''
        });

        return false;

    });

【讨论】:

  • 我将如何自动加载它,目前它有“$('#add-regular').click(function(){”,我如何从后面的代码自动加载它,谢谢
猜你喜欢
  • 1970-01-01
  • 2012-11-12
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-08-01
  • 2013-07-07
  • 1970-01-01
相关资源
最近更新 更多