gpt4 book ai didi

javascript - 停止执行 javascript

转载 作者:行者123 更新时间:2023-11-30 13:03:56 25 4
gpt4 key购买 nike

我知道这很简单,但我无法让下面的条件 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com