1

我知道这很简单,但如果下面的工作我无法获得条件......

" if ( !$section.id == "no-transition" ) " 下面的这一行是不正确的。

我试图阻止 javascript 处理具有“无过渡”标识的部分元素。

有人可以指出我正确的方向吗?

function initEvents() {

    $sections.each( function() {

            var $section = $( this );

            if ( !$section.id == "no-transition" ) { 
            // expand the clicked section and scale down the others
            $section.on( 'click', function() {

                    [code taken out to shorten post...]

                    if( !supportTransitions ) {
                            $section.removeClass( 'bl-expand-top' );
                    }

                    $el.removeClass( 'bl-expand-item' );

                    return false;

            } );
           }
} );
4

1 回答 1

3

你真的不应该在一个页面上有多个具有相同 id 的元素。

您的if条件应修改为:

...
if ( $section.attr('id') != "no-transition" ) { 
   ...
于 2013-05-04T14:01:24.760 回答