[英]Stop javascript from executing
I know this is simple but I cant get the conditional if below to work... 我知道这很简单,但我无法获得条件,如果下面的工作......
This line below " if ( !$section.id == "no-transition" ) " is not correct. “if(!$ section.id ==”no-transition“)”下面的这一行不正确。
I'm trying to stop javascript from working on section elements that have the id of "no-transition". 我试图阻止javascript处理id为“no-transition”的节元素。
Can someone point me in the right direction? 有人能指出我正确的方向吗?
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;
} );
}
} );
You really should not have multiple elements with the same id on a page. 你真的不应该在页面上有多个具有相同id的元素。
Your if condition should be modified to: 您的if条件应修改为:
...
if ( $section.attr('id') != "no-transition" ) {
...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.