开发者

skip click function based on dynamically assigned class value

I have a table that reveals further details of a record when its is clicked. The details reside in a child div with the class 'description'. I've got the exposure toggling just fine, but I would like to avoid having the click function called on elements that have already been exposed (i.e. i don't want to re-display what's already being displayed).

I've tried .bind and .live with no luck. Basically, I'm hoping there's some way to allow the new class assignment to be 'activated' in the DOM.

开发者_开发问答

Thanks in advance for your help!

jQUERY

$(document).ready(function(){

        $('#libraryBrowser tbody tr:not(.exposed)').click(function(){
            $('.exposed').slideUp('fast');                                                          //hide previously shown element
            $(this).find('div.description').slideToggle('slow').addClass('exposed');                //show selected item's description, flag exposure
        });

});


i don't want to re-display what's already being displayed

You can use is with :visible filter selector to see if an element is already visible and if it is, you simply need to exit out of the function using return false something like this:

if ('.yourelementclass').is(':visible')){
  return false;
}

You need to put in that code just before the code where you actually show the image.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜