addClass (className)
Adds the specified class(es) to each element in the set of matched elements.
<div class="container border-sm border-info pad-md" id="exampleContainer"> <div class="row gap-sm pad-items-md text-center" id="containerChild"> <div class="col-bp-2-over border-sm" id="element0">Label 0</div> <div class="col-bp-2-over border-sm" id="element1">Label 1</div> <div class="col-bp-2-over border-sm" id="element2">Label 2</div> </div> </div>
webui.ready( () => { ui("#containerChild div").addClass("warning-light height-md"); });
append (elements, appendToStart)
Appends the specified elements or DOM fragment to each element in the set of matched elements or DOM fragment. Element objects specified as the first argument can be an HTMLElement, a WebUI onject, or a valid DOM fragment. If a valid DOM fragment string is specified, a new DOM element is created and converted to a WebUI object, and then appended.
<div class="container border-sm border-info pad-md" id="exampleContainer"> <div class="row gap-sm pad-items-md text-center" id="containerChild"> <div class="col-bp-2-over border-sm" id="element0">Label 0</div> <div class="col-bp-2-over border-sm" id="element1">Label 1</div> <div class="col-bp-2-over border-sm" id="element2">Label 2</div> </div> </div>
webui.ready( () => { ui("#containerChild").append("<div class='col-bp-2-over border-sm'>Label 3</div>"); });
appendTo (to)
This method is similar to append(), but appends the matched elements or DOM fragment to a specified target element or DOM fragment at the end of the node list.
<div class="container border-sm border-info pad-md" id="exampleContainer"> <div class="row gap-sm pad-items-md text-center" id="containerChild"> <div class="col-bp-2-over border-sm" id="element0">Label 0</div> <div class="col-bp-2-over border-sm" id="element1">Label 1</div> <div class="col-bp-2-over border-sm" id="element2">Label 2</div> </div> </div>
webui.ready( () => { ui("<div class='col-bp-2-over border-sm'>Label 3</div>").appendTo(ui("#containerChild")); });
attr (attrName)
Gets the specified attribute values of each element in the set of matched elements.
<div class="container border-sm border-info pad-md" id="exampleContainer"> <div class="row gap-sm pad-items-md text-center" id="containerChild"> <div class="col-bp-2-over border-sm" id="element0">Label 0</div> <div class="col-bp-2-over border-sm" id="element1">Label 1</div> <div class="col-bp-2-over border-sm" id="element2">Label 2</div> </div> </div>
webui.ready( () => { let ids = ui("#containerChild div").attr("id"); });
attr (attrName, attrValue)
Sets the specified attribute value for each element in the set of matched elements.
<div class="container border-sm border-info pad-md" id="exampleContainer"> <div class="row gap-sm pad-items-md text-center" id="containerChild"> <div class="col-bp-2-over border-sm" id="element0">Label 0</div> <div class="col-bp-2-over border-sm" id="element1">Label 1</div> <div class="col-bp-2-over border-sm" id="element2">Label 2</div> </div> </div>
webui.ready( () => { ui("#containerChild div").first().attr("id", "div1"); ui("#containerChild div").last().attr("id", "div2") });
css (ruleName)
Gets the specified computed css property values of each element in the set of matched elements.
<div class="container border-sm border-info pad-md" id="exampleContainer"> <div class="row gap-sm pad-items-md text-center" id="containerChild"> <div class="col-bp-2-over border-sm" id="element0">Label 0</div> <div class="col-bp-2-over border-sm" id="element1">Label 1</div> <div class="col-bp-2-over border-sm" id="element2">Label 2</div> </div> </div>
webui.ready( () => { let heights = ui("#containerChild div").css("height"); });
css (ruleName, ruleValue)
Sets the specified css property value for each element in the set of matched elements.
<div class="container border-sm border-info pad-md" id="exampleContainer"> <div class="row gap-sm pad-items-md text-center" id="containerChild"> <div class="col-bp-2-over border-sm" id="element0">Label 0</div> <div class="col-bp-2-over border-sm" id="element1">Label 1</div> <div class="col-bp-2-over border-sm" id="element2">Label 2</div> </div> </div>
webui.ready( () => { ui("#containerChild div").first().css("height", "5rem"); ui("#containerChild div").last().css("height", "5rem") });
data (dataName)
Gets the specified data attribute values of each element in the set of matched elements.
<div class="container border-sm border-info pad-md" id="exampleContainer"> <div class="row gap-sm pad-items-md text-center" id="containerChild"> <div class="col-bp-2-over border-sm" id="element0" data-percent="0">Label 0</div> <div class="col-bp-2-over border-sm" id="element1" data-percent="50">Label 1</div> <div class="col-bp-2-over border-sm" id="element2" data-percent="100">Label 2</div> </div> </div>
webui.ready( () => { let percentages = ui("#containerChild div").data("percent"); });
data (dataName, dataValue)
Sets the specified data attribute value for each element in the set of matched elements.
<div class="container border-sm border-info pad-md" id="exampleContainer"> <div class="row gap-sm pad-items-md text-center" id="containerChild"> <div class="col-bp-2-over border-sm" id="element0" data-percent="0">Label 0</div> <div class="col-bp-2-over border-sm" id="element1" data-percent="50">Label 1</div> <div class="col-bp-2-over border-sm" id="element2" data-percent="100">Label 2</div> </div> </div>
webui.ready( () => { ui("#containerChild div").first().data("percent", "10"); ui("#containerChild div").last().data("percent", "75") });
hasClass (className)
Determines whether the specified class(es) exist on any element in the set of matched elements.
<div class="container border-sm border-info pad-md" id="exampleContainer"> <div class="row gap-sm pad-items-md text-center" id="containerChild"> <div class="col-bp-2-over border-sm" id="element0">Label 0</div> <div class="col-bp-2-over border-sm" id="element1">Label 1</div> <div class="col-bp-2-over border-sm" id="element2">Label 2</div> </div> </div>
webui.ready( () => { let hasBorderSm = ui("#containerChild div").hasClass("border-sm"); });
hidden ()
Sets the visibility property to hidden of each element in the set of matched elements.
<div class="container border-sm border-info pad-md" id="exampleContainer"> <div class="row gap-sm pad-items-md text-center" id="containerChild"> <div class="col-bp-2-over border-sm" id="element0">Label 0</div> <div class="col-bp-2-over border-sm" id="element1">Label 1</div> <div class="col-bp-2-over border-sm" id="element2">Label 2</div> </div> </div>
webui.ready( () => { ui("#containerChild div").first().hidden(); });
hide ()
Sets the display property to none of each element in the set of matched elements.
<div class="container border-sm border-info pad-md" id="exampleContainer"> <div class="row gap-sm pad-items-md text-center" id="containerChild"> <div class="col-bp-2-over border-sm" id="element0">Label 0</div> <div class="col-bp-2-over border-sm" id="element1">Label 1</div> <div class="col-bp-2-over border-sm" id="element2">Label 2</div> </div> </div>
webui.ready( () => { ui("#containerChild div").first().hide(); });
html ()
Gets the inner html of each element in the set of matched elements.
<div class="container border-sm border-info pad-md" id="exampleContainer"> <div class="row gap-sm pad-items-md text-center" id="containerChild"> <div class="col-bp-2-over border-sm" id="element0">Label 0</div> <div class="col-bp-2-over border-sm" id="element1">Label 1</div> <div class="col-bp-2-over border-sm" id="element2">Label 2</div> </div> </div>
webui.ready( () => { let htmlContent = ui("#containerChild").html(); });
html (value)
Sets the specified inner html fragment for each element in the set of matched elements.
<div class="container border-sm border-info pad-md" id="exampleContainer"> <div class="row gap-sm pad-items-md text-center" id="containerChild"> <div class="col-bp-2-over border-sm" id="element0">Label 0</div> <div class="col-bp-2-over border-sm" id="element1">Label 1</div> <div class="col-bp-2-over border-sm" id="element2">Label 2</div> </div> </div>
webui.ready( () => { ui("#exampleDiv").html("<div class='width-xs height-sm background-dark'></div>"); });
prependTo (to)
This method is similar to appendTo(), but prepends the matched elements or DOM fragment to a specified target element or DOM fragment at the start of the node list.
<div class="container border-sm border-info pad-md" id="exampleContainer"> <div class="row gap-sm pad-items-md text-center" id="containerChild"> <div class="col-bp-2-over border-sm" id="element0">Label 0</div> <div class="col-bp-2-over border-sm" id="element1">Label 1</div> <div class="col-bp-2-over border-sm" id="element2">Label 2</div> </div> </div>
webui.ready( () => { ui("<div>Element 3</div>").prependTo(ui("#containerChild")); });
remove ()
Removes each element in the set of matched elements.
<div class="container border-sm border-info pad-md" id="exampleContainer"> <div class="row gap-sm pad-items-md text-center" id="containerChild"> <div class="col-bp-2-over border-sm" id="element0">Label 0</div> <div class="col-bp-2-over border-sm" id="element1">Label 1</div> <div class="col-bp-2-over border-sm" id="element2">Label 2</div> </div> </div>
webui.ready( () => { ui("#containerChild div").remove(); });
removeChildren ()
Removes all child elements of each element in the set of matched elements.
<div class="container border-sm border-info pad-md" id="exampleContainer"> <div class="row gap-sm pad-items-md text-center" id="containerChild"> <div class="col-bp-2-over border-sm" id="element0">Label 0</div> <div class="col-bp-2-over border-sm" id="element1">Label 1</div> <div class="col-bp-2-over border-sm" id="element2">Label 2</div> </div> </div>
webui.ready( () => { ui("#containerChild").removeChildren(); });
removeClass (className)
Removes the specified class(es) from each element in the set of matched elements, or removes all classes from the class list if an astersik (*) is specified instead.
<div class="container border-sm border-info pad-md" id="exampleContainer"> <div class="row gap-sm pad-items-md text-center" id="containerChild"> <div class="col-bp-2-over border-sm" id="element0">Label 0</div> <div class="col-bp-2-over border-sm" id="element1">Label 1</div> <div class="col-bp-2-over border-sm" id="element2">Label 2</div> </div> </div>
webui.ready( () => { ui("#containerChild div").removeClass("border-lg border-dark"); ui("#containerChild div").removeClass("*"); // Removes all classes });
setControlState (currentCssClass, newCssClass, controlMessage, revertOnClick, resetData)
Replaces an existing class with a new class on each element in the set of matched elements, optionally sets a text value if possible, optionally reverts all changes when clicked or tapped, and optionally clears a controls data.
<div class="flex flex-direction-column gap-xs width-xl pad-xl"> <input id="textURL" type="text" class="input-lg rounded-md width-full" data-validation-text="textURLMessage" /> <label id="textURLMessage" class="control-message text-sm text-italic height-control-sm"></label> <button class="button-lg button-info rounded-md feedback-active" id="buttonValidate">Validate</button> </div>
webui.ready( () => { ui("#buttonValidate").click(() => { if (!ui("#textURL").hasConformingString(ui.URL, false)) { ui("#textURL").setControlState("", "control-danger", "Please enter a valid URL", false, false); } else { ui("#textURL").setControlState("control-danger", "control-success"); } }); });
show (displayType)
Sets the display property to the specified display type of each element in the set of matched elements.
<div class="container border-sm border-info pad-md" id="exampleContainer"> <div class="row gap-sm pad-items-md text-center" id="containerChild"> <div class="col-bp-2-over border-sm" id="element0">Label 0</div> <div class="col-bp-2-over border-sm" id="element1">Label 1</div> <div class="col-bp-2-over border-sm" id="element2">Label 2</div> </div> </div>
webui.ready( () => { ui("#exampleContainer > div").first().show("flex"); });
text ()
Gets the text content of each element in the set of matched elements.
<div class="container border-sm border-info pad-md" id="exampleContainer"> <div class="row gap-sm pad-items-md text-center" id="containerChild"> <div class="col-bp-2-over border-sm" id="element0">Label 0</div> <div class="col-bp-2-over border-sm" id="element1">Label 1</div> <div class="col-bp-2-over border-sm" id="element2">Label 2</div> </div> </div>
webui.ready( () => { let divTextContent = ui("#exampleDiv").text(); let textareaTextContent = ui("#exampleTextarea").text(); });
text (value)
Sets the specified text content for each element in the set of matched elements.
<div class="container border-sm border-info pad-md" id="exampleContainer"> <div class="row gap-sm pad-items-md text-center" id="containerChild"> <div class="col-bp-2-over border-sm" id="element0">Label 0</div> <div class="col-bp-2-over border-sm" id="element1">Label 1</div> <div class="col-bp-2-over border-sm" id="element2">Label 2</div> </div> </div>
webui.ready( () => { ui("#exampleDiv").text("10"); ui("#exampleTextarea").text("Example text"); });
toggle ()
Shows or hides all elements in the set of matched elements, and sets the aria-hidden attribute to either true or false.
<div class="container border-sm border-info pad-md" id="exampleContainer"> <div class="row gap-sm pad-items-md text-center" id="containerChild"> <div class="col-bp-2-over border-sm" id="element0">Label 0</div> <div class="col-bp-2-over border-sm" id="element1">Label 1</div> <div class="col-bp-2-over border-sm" id="element2">Label 2</div> </div> </div>
webui.ready( () => { ui("#toggleButton").click( () => { ui("#containerChild div").toggle(); }); });
toggle (toggleState)
Shows or hides all elements in the set of matched elements depending on the toggleState argument, and sets the aria-hidden attribute to either true or false.
<div class="container border-sm border-info pad-md" id="exampleContainer"> <div class="row gap-sm pad-items-md text-center" id="containerChild"> <div class="col-bp-2-over border-sm" id="element0">Label 0</div> <div class="col-bp-2-over border-sm" id="element1">Label 1</div> <div class="col-bp-2-over border-sm" id="element2">Label 2</div> </div> </div>
webui.ready( () => { ui("#toggleButtonOn").click( () => { ui("#containerChild div").toggle("on"); }); ui("#toggleButtonOff").click( () => { ui("#containerChild div").toggle("off"); }); });
toggleClass (className)
Toggles the addition or removal of a class or set of classes for all elements in the set of matched elements.
<div class="container border-sm border-info pad-md" id="exampleContainer"> <div class="row gap-sm pad-items-md text-center" id="containerChild"> <div class="col-bp-2-over border-sm" id="element0">Label 0</div> <div class="col-bp-2-over border-sm" id="element1">Label 1</div> <div class="col-bp-2-over border-sm" id="element2">Label 2</div> </div> </div>
webui.ready( () => { ui("#toggleButton").click( () => { ui("#containerChild div").toggleClass("background-dark"); }); });
val ()
Gets the value of each element in the set of matched elements.
<div class="container border-sm border-info pad-md" id="exampleContainer"> <div class="row gap-sm pad-items-md text-center" id="containerChild"> <div class="col-bp-2-over border-sm" id="element0">Label 0</div> <div class="col-bp-2-over border-sm" id="element1">Label 1</div> <div class="col-bp-2-over border-sm" id="element2">Label 2</div> </div> </div>
webui.ready( () => { let textInputValue = ui("#exampleInput").val(); let selectInputValue = ui("#exampleSelect").val(); });
val (value)
Sets the specified value for each element in the set of matched elements.
<div class="container border-sm border-info pad-md" id="exampleContainer"> <div class="row gap-sm pad-items-md text-center" id="containerChild"> <div class="col-bp-2-over border-sm" id="element0">Label 0</div> <div class="col-bp-2-over border-sm" id="element1">Label 1</div> <div class="col-bp-2-over border-sm" id="element2">Label 2</div> </div> </div>
webui.ready( () => { ui("#exampleInput").val("10"); ui("#exampleSelect").val("5"); });
visible ()
Sets the visibility property to visible of each element in the set of matched elements.
<div class="container border-sm border-info pad-md" id="exampleContainer"> <div class="row gap-sm pad-items-md text-center" id="containerChild"> <div class="col-bp-2-over border-sm" id="element0">Label 0</div> <div class="col-bp-2-over border-sm" id="element1">Label 1</div> <div class="col-bp-2-over border-sm" id="element2">Label 2</div> </div> </div>
webui.ready( () => { ui("#containerChild div").first().visible(); });