function
setup() {
createCanvas(550, 300);
textSize(18);
text(
"Click on the buttons to add the given "
+
"class to the element"
, 20, 20);
setBtn =
createButton(
"Add given class to element"
);
setBtn.position(30, 40);
setBtn.mouseClicked(addNewClass);
setBtn =
createButton(
"Show current classes"
);
setBtn.position(300, 40);
setBtn.mouseClicked(showClasses);
class_name = createInput(
'class1'
);
class_name.position(30, 80);
tmpElement = createElement(
"div"
);
}
function
addNewClass() {
clear();
let classToSet = class_name.value();
tmpElement.addClass(classToSet);
text(
"Class added with name: "
+
classToSet, 30, 120);
text(
"Click on the button to add the given "
+
"class 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 to the element"
, 20, 20);
}