jQuery Selector Question -


I'm actually doing an Ardiion / Sliding menu here, I want to open brother Ule (or displayed) ). Can I simplify it further?

$ (this). Parent ("li") Siblings ("li: is (ul)"). Children ("UL") SlideUp ("Sharp");

I have also found that I can not leave children () and do something

  $ (this). Parent ("li") Brother Sister ("Lee: is (ul) ul"). SlideUp ("Sharp"); "Brother-sister" ("Lee: is (ul)"). Children ("ul")?   

In the first case, you are selecting list elements which are siblings, unless those list elements are listed as children, you In the second case, you are looking for the brothers and sisters who are listed in the list which are children of the list elements (instant or nested). The problem is that you have a list element brother Looking in the ship The old list is not siblings (only list element siblings).

The main thing is that the selector of the siblings method is a filter; it is used only to select from the list of unique siblings, those siblings who meet the criteria specified in the selector Are there. In your case, there are no siblings who can match the criteria in the second case.

Example:

  & lt; Ul & gt; & Lt; Li id = 'li0' class = 'selected' & gt; & Lt; Ul id = 'ul0' class = 'child' & gt; ... & lt; / Ul & gt; & Lt; / Li & gt; & Lt; Li id = 'li1' class = 'bro' & gt; & Lt; Ul id = 'ul 1' class = 'child' & gt; ... & lt; / Ul & gt; & Lt; / Li & gt; & Lt; Li id = 'li2' square = 'bro' & gt; & Lt; Ul id = 'ul2' class = 'child' & gt; & Lt; Li id = 'li2_0' class = 'granddaughter' & gt; & Lt; Ul id = 'ul2_0' square = 'Greater British' & gt; ... & lt; / Ul & gt; & Lt; / Li & gt; & Lt; / Ul & gt; & Lt; / Li & gt; & Lt; Li id = 'li3' & gt; & Lt; / Li & gt; & Lt; / Ul & gt;  

$ ('. Selected'). Brother Sister ('li: is (ul)') will return collection of list elements with ID li1 and li2 . $ ('selected'). Brother Sister ('li: is (ul) ul') will return a blank set because it is similar to $ ('. Selected'). Brother Sister () Filter ('li: is (ul) ul'). Since siblings return sets set with icedes li1 'and li2`, they do not match the filter, which selects children with an inventory list of list element (with unauthorized list children). .

You can see the effect by using the following snippet of code.

dumpIds ('brother-sister', $ ('selected.'); Siblings (); dumps ('filtered sebs', $ (' Brother 's sister (' li: is (ul) ')); dumps (' ul filtered sibbs', $ ('selected'). Siblings ('li: isa') ul)); }); Function dumps (title, element) {var idset = ''; Var sep = ''; Elements.each (function () {idset = idset + sep + this.id; sep = ',';}); Warning (title + ':' + idset); }


Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -