-
Notifications
You must be signed in to change notification settings - Fork 57
$.custom()
Arthur Guiot edited this page Jul 5, 2017
·
1 revision
Do you like the $.var()
or the $.target()
function? Do you want to create a function that will basically interact with an element, depending on their HTML tags? Well, the $.custom()
function is made for you.
You simply need to give it the target attribute, the function to apply to each element and the push time (optional).
For the example, we'll recreate the $.var()
function. Here is how we'll do it:
JS:
// Creating $varEmulation, with arguments the domain (most of the cases it will be window) and the push time.
function $varEmulation (domain, push) {
// custom function with for arguments: targetAttr = "var", callback = function (element, attr) { ... } (see below), push = push
$.custom("var", function(element, attr) {
// from the current element, replace it's HTML by the variable written in the var="..." attribute
element.innerHTML = domain[attr];
}, push)
}
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()