I implement an accordion style behavior where only one element can be displayed at one point. I thought it would be easier to implement a function show(e)that displays an element ethat will be displayed and hides everything, BUT e. This saves me the hassle of tracking which item is displayed. I could just attach show(e)as a callback for each element of the accordion.
To do this, I thought that the only way is to use .each()all ad elements comparing each with eto hide it, hiding it if it is not equal e.
However, I remember that there is a jQuery function .filter(http://api.jquery.com/filter/), but it only matches the element, not the other way around. (i.e. if I call the function and pass it e, it will only match e, not all BUT e.)
Is there a way to do this, or are there recommendations for making the accordion as a whole? Thanks in advance!
source
share