我知道这很简单,但我无法让下面的条件 if 起作用...
“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" ) {
...
关于javascript - 停止执行 javascript,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16375100/