-
Notifications
You must be signed in to change notification settings - Fork 57
Text related
This function will simply put the text you have written into an element (obviously what did you expect 😂). This function will run the $.xss() function before putting the text.
JS:
$.text($.select(".myCoolElement"), "Hello World 🌎!")
// Hello World 🌎!I won't detail much about this function because it's exactly the same as $.text(), but without running the $.xss() function. I don't think 🤔 you need an example for this.
This function will basically take the content of an element and add some HTML.
Let's say you want to do a fancy countdown, like Countdown: 1...2...3... Boum!.
HTML:
<h1>Countdown: </h1>JS:
var i = 0
window.setInterval(function() {
i++;
if(i > 0 && i < 3) {
$.append($.select("h1"), i + "...")
}
else if (i == 4) {
$.append($.select("h1"), "Boum!")
}
else {
// Do nothing
}
}, 1000)These function will basically insert adjacent HTML after and before the selected element.
HTML:
<div class="testEl">I'll have before and after HTML when DisplayJS will do its work</div>JS:
$.before($.select(".testEl"), "<h1>Hello, I'm the before HTML</h1>")
$.after($.select(".testEl"), "<h1>Hello, I'm the after HTML</h1>")This function will empty the content of an element (not inputs, for that, see the $.emptyVal() function). You simply have to give it the element and it will empty it.
HTML:
<h1>I'm sad 😭, I'll be empty soon</h1>JS:
$.empty($.select("h1"))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()