开发者

jQuery determine if selected element's CSS has certain property via identifying attribute

开发者 https://www.devze.com 2023-03-29 06:35 出处:网络
I have a UL list inside that UL list is a handful of LI\'s that 开发者_开发问答all have \"rel\" attributes as identifying tokens as the ID/Class tags have been used for other reasons. Anyway this is w

I have a UL list inside that UL list is a handful of LI's that 开发者_开发问答all have "rel" attributes as identifying tokens as the ID/Class tags have been used for other reasons. Anyway this is what I am attempting currently

if($('#column1').find('li:[rel='+theElements[i]+']').css({'opacity':0})){hideit = true;}else{hideit = false;}

Which finds the right column, but then turns around and hides the whole column. I definately feel as though I am approaching this the wrong way. I tried .is(':visible') but I don't think that worked properly for me. Anyone have an Idea?

What I am doing based on the "hideit =" part is building a JSON string to control the layout and save things for a later date for my users.


You are setting the opacity instead of reading it. Do this:

if($('#column1').find('li:[rel='+theElements[i]+']').css('opacity') == 0) {
    hideit = true;
} else {
    hideit = false;
}


Sounds like you're looking for something like:

$(theElements).each(function()
{
    var elem = $('#column1').find('li:[rel=' + this + ']');
    if(elem.css('opacity') === 0)
       elem.hide();
});
0

精彩评论

暂无评论...
验证码 换一张
取 消