打开滑块时怎么办?

时间:2011-06-06 00:10:01

标签: jquery events onclick slider

/* Toggle*/
        $(function(){
        $(".collapsible-content").hide();
        $('.news-trigger').toggle(
            function() {
                $(this).toggleClass("opened").parent().next().slideDown();
                $(this).html('Close <img src="img/button-arrow-up.png" alt="" class="collapse-arrow-up">');
                },
            function() {
                $(this).toggleClass("opened").parent().next().slideUp();
                $(this).html('Red more...');
            }
        );
    });
    /* End */

如何包含\ /仅当我打开上滑块

/* Count clicks */
$(".count").click(function(){
    var id = $(this).attr('id');
    $.get("counter.php?id="+id);
    });

1 个答案:

答案 0 :(得分:0)

不太清楚你的意思?

当您切换'news-trigger'时,您想要调用您的点击功能吗?

如果是这种情况,您可能只想第一次调用它。

    var check = 1;
    $(function(){
        $(".collapsible-content").hide();
        $('.news-trigger').toggle(

            function() {

                $(this).toggleClass("opened").parent().next().slideDown();
                $(this).html('Close <img src="img/button-arrow-up.png" alt="" class="collapse-arrow-up">');
                if(check == 1){
                    $(".count").click(function(){
                         var id = $(this).attr('id');
                         $.get("counter.php?id="+id);
                             }, check = 0);
                         }

                },
            function() {
                $(this).toggleClass("opened").parent().next().slideUp();
                $(this).html('Red more...');

            }

        );
    });
相关问题