@frostsw/frostjs
v1.2.21
Published
A lightweight JS for basic DOM manipulation and more.
Downloads
5
Readme
FrostJS
A lightweight JS for basic DOM manipulation and more.
FrostJS Initialisation
You can initialise FrostJS using fr alias
You can have multiple fr(function(){ }); in a single script if necessary, but keep in mind that one of this instance will be enough. fr() functions, or any function, that is used to bind events must be called through this function, otherwise the browser will throw fr is undefined error. Numbers Only fr("#txtText").typing(FrostJS.Typing.NUMBERS); Titlecase This is a text area fr("#area").typing(FrostJS.Typing.TITLECASE); Binding an event You can bind an event to an element using .on() method. For list of DOM events, click here. Syntax: frObject.on("event_name", callback); callback must be in a form of anonymous function or an existing function name .
// Using an existing function name: fr("#myBtn").on("blur", myFunction);
function myFunction(){ //code to trigger }
fr("#switch2").on("click", function (e) { fr("#switch2").class("active", "inactive"); fr("#switch1").class("inactive", "active"); }); .class() method can be used to add/remove classes.