Hi, I have a basic count up html file, along with JS as shown below. I either want to apply this to a piece of text or create a piece of text that when the counter comes into the viewport it starts to count up to a predefined figure and stops. Any help would be gratefully appreciated and if you need more information please do let me know.
0
0
0
$(‘.counter’).each(function() {
var $this = $(this),
countTo = $this.attr(‘data-count’);
WixCode understands all of Javascript, except for anything that accesses the DOM.
This keeps the user from inadvertently “breaking” something. I myself tried to hack things from the code, from an iFrame, and in my dreams, but WixCode wasn’t having any of it.
Accessing document elements such as div, span, button, etc is off-limits. The way to access elements on the page is only through $w.
One small exception is the $w.HtmlComponent (which is based on an iFrame). This element was designed to contain vanilla HTML and it works just fine. You just can’t try to trick it by using parent, window, top, etc. Same goes with the Javascript evaluate() function. It is sandboxed and does not allow access to the DOM.