Введите переменную в JQuery - PullRequest
0 голосов
/ 24 апреля 2011

Привет, я хочу использовать следующую функцию

$('#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 вызывалась, когданажата кнопка, пожалуйста, дайте мне знать, как я могу это сделать.Спасибо

1 Ответ

1 голос
/ 24 апреля 2011

попробуйте это:

ASP:

<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;

    });
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...