function
setup() {
createCanvas(550, 300);
textSize(18);
text(
"Click on the button to add the given "
+
"class(es) to the element"
, 20, 20);
setBtn =
createButton(
"Create new Element with given classes"
);
setBtn.position(30, 40);
setBtn.mouseClicked(createNewElement);
setBtn =
createButton(
"Show Last Element class"
);
setBtn.position(300, 40);
setBtn.mouseClicked(showClasses);
class_name = createInput(
'tmpClass'
);
class_name.position(30, 80);
}
function
createNewElement() {
clear();
tmpElement = createElement(
"div"
);
let classToSet = class_name.value();
tmpElement.class(classToSet);
text(
"Class set with the names: "
+
classToSet, 30, 120);
text(
"Click on the button to add the given "
+
"class(es) to the element"
, 20, 20);
}
function
showClasses() {
clear();
let setClasses = tmpElement.class();
text(
"The classes of the element are: "
+
setClasses, 30, 120);
text(
"Click on the button to add the given "
+
"class(es) to the element"
, 20, 20);
}