-
Notifications
You must be signed in to change notification settings - Fork 57
$.parent()
Arthur Guiot edited this page Jul 25, 2017
·
1 revision
This function is pretty useful when you're dealing with relative elements because it will make you able to select the parent of an element. Like the .parentNode
property from JavaScript.
But we push the concept forward by making you able to select the parent of the parent or the parent of the parent of the parent, etc... You see the concept.
For that, you only need to give how far you want to go.
Parent | level |
---|---|
Only the parent | 0 |
Parent of the parent | 1 |
Parent of the parent of the parent | 2 |
... | ... |
This function will take 2 arguments:
-
element
- the child -
n
(optional) - The level. By defaultn = 0
HTML:
<div class="container">
<div class="foo">
<div class="bar"></div>
</div>
</div>
JS:
$.parent($.s(".bar")) // == $.s(".foo")
$.parent($.s(".bar"), 1) // == $.s(".container")
Don't hesitate to ask your questions
- Home
- The Core Languages
- Getting Started: Installation
- The Basics (
$.var()
+$.target()
) - Developing for DisplayJS
-
$.select()
- Text related
- If...else
$.xss()
$.repeat()
$.custom()
$.live()
$.load()
$.on()
$.onEvent()
$.ready()
- Scroll API
$.all()
$.clone()
$.is()
$.valEmpty()
$.remove()
$.show()
&$.hide()
$.ajax()
- Class Related
$.css()
$.getStyle()
- Fade effects
$.extend()
$.dynamic()
$.parent()
- Elements-Nodes
$.component()
$.time_ago()
$.copy()
$.then()
$.sleep()
$.getProp()