Jquery执行的操作超出了应有的范围

时间:2016-01-28 15:09:13

标签: jquery wordpress

当有人点击课程console.log时,我正试图触发pane-2-0。 整个代码都有效,但当我尝试单击pane-2-0类的元素时,它会记录F class send to consoleV class send to consoleK class send to console。其余的代码不会发生这种情况。当我点击pane-2-1, .active元素时,它只会记录V class send to console。我想弄清楚的是第一个pane-2-0执行三个函数的原因。

有三个主要标签/窗格; pane2-0pane2-1pane2-2responsive-tabs嵌套在三个窗格中。 #tablist1-tab1#tablist1-tab3嵌套在pane2-0下,#tablist2-tab1#tablist2-tab3嵌套在pane2-2下。

当我尝试点击#tablist1-tab1#tablist1-tab3时,会发生同样的事情。它会记录我点击的标签以及V class send to logK class send to log

单击pane2-1pane2-2时不会发生这种情况。即使将#tablist2-tab1记录到#tablist2-tab3也能完美运行。将.active添加到选择器无效

jQuery(function($) {
    $('.pane-2-0').on('click', function(){
        console.log("F class send to console");
    });

    $('.pane-2-1, .active').on('click' , function(){
        console.log("V class send to console");
    });

    $('.pane-2-2, .active').on('click', function(){
        console.log("K class send to console");
    });

    $('.responsive-tabs').on('click', '#tablist1-tab1', function() {
        console.log("Financials Financials class send to console");
    });

    $('.responsive-tabs').on('click', '#tablist1-tab2', function() {
        console.log("Financials balans class send to console");
    });

    $('.responsive-tabs').on('click', '#tablist1-tab3', function() {
        console.log("Financials Cash Flow class send to console");
    });

    $('.responsive-tabs').on('click', '#tablist2-tab1', function() {
        console.log("KR Margins");
    });

    $('.responsive-tabs').on('click', '#tablist2-tab2', function() {
        console.log("KR Balans");
    });

    $('.responsive-tabs').on('click', '#tablist2-tab3', function() {
        console.log("KR gezondheid");
    });
});

0 个答案:

没有答案