-1

我似乎无法弄清楚我的 if 有什么问题,有人可以帮助我吗

$("#tablet_windows").on('click', function(){
    $( ".demo-divs .span3" ).each(function( index ) {
        var that = $(this);
        if(!that.hasClass('opacity')) {
            //this line is wrong
            that.find('.attributes-container .tablet_windows').length == 0;  { 
            that.toggleClass('opacity');
            that.find('.rating').toggleClass('opacity');
            }
        }
    });
});
4

4 回答 4

4

问题是if缺少:

改变

that.find('.attributes-container .tablet_windows').length == 0;  { //this line is wrong

if (that.find('.attributes-container .tablet_windows').length == 0) {
于 2013-05-23T11:29:46.893 回答
0

更改此行:(缺少 if

that.find('.attributes-container .tablet_windows').length == 0;  { 

应该是这样的 -

$("#tablet_windows").on('click', function(){
    $( ".demo-divs .span3" ).each(function( index ) {
        var that = $(this);
        if(!that.hasClass('opacity')) {
            if(that.find('.attributes-container .tablet_windows').length == 0)  { //this line is wrong
            that.toggleClass('opacity');
            that.find('.rating').toggleClass('opacity');
            }
        }
    });
});
于 2013-05-23T11:29:49.983 回答
0
$("#tablet_windows").on('click', function(){
$( ".demo-divs .span3" ).each(function( index ) {
    var that = $(this);
    if(!that.hasClass('opacity')) {
     if(that.find('.attributes-container .tablet_windows').length == 0)  {
        that.toggleClass('opacity');
        that.find('.rating').toggleClass('opacity');
        }
    }
});
});
于 2013-05-23T11:31:40.780 回答
0
  if(that.find('.attributes-container .tablet_windows').length == 0)
{
            that.toggleClass('opacity');
            that.find('.rating').toggleClass('opacity');
            }
于 2013-05-23T11:31:55.367 回答