簡體   English   中英

停止執行javascript

[英]Stop javascript from executing

我知道這很簡單,但我無法獲得條件,如果下面的工作......

“if(!$ section.id ==”no-transition“)”下面的這一行不正確。

我試圖阻止javascript處理id為“no-transition”的節元素。

有人能指出我正確的方向嗎?

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;

            } );
           }
} );

你真的不應該在頁面上有多個具有相同id的元素。

您的if條件應修改為:

...
if ( $section.attr('id') != "no-transition" ) { 
   ...

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM