top of page
Anchor 1
Wix Tutorial - Create a word counter, using Wix Code
Add a word counter to your text box.
Elements:
User Input:
-
box: #colorBox
Wix Code:
export function textBox1_keyPress(event) {
setTimeout(() => {
let val = event.target.value;
if(val.length === 0)
return;
let count = WordCount(val);
$w("#count").text = "" + count;
}, 10);
}
function WordCount(str) {
return str.split(" ").length;
}
Demo:
Number of words in text:
Count
bottom of page