Hi, I have an id $w('text9') on my Home page and want to use this npm package that I can't link to, so here's how the code looks like with DOM:
var app = document.getElementById('app');
var typewriter = new Typewriter(app, {
loop: true,
delay: 75,
});
typewriter
.pauseFor(2500)
.typeString('A simple yet powerful native javascript')
.pauseFor(300)
.deleteChars(10)
.pauseFor(1000)
.start();
However, I'm having trouble figuring out how to do this with $w instead of DOM.
I was thinking of doing something like:
import Typewriter from 'typewriter-effect/dist/core';
$w.onReady(function () {
// Write your JavaScript here
// To select an element by ID use: $w("#elementID")
// Click "Preview" to run your code
var app = $w('#text9')
var typewriter = new Typewriter(app, {
loop: true,
delay: 75,
});
typewriter
.pauseFor(2500)
.typeString($w('#text9')).text
.pauseFor(300)
.deleteChars(10)
.pauseFor(1000)
.start();
});
Options:
![](https://static.wixstatic.com/media/ba5770_abd8b88e8249406ebeee92f2f04e8491~mv2.png/v1/fill/w_49,h_60,al_c,q_85,usm_0.66_1.00_0.01,blur_2,enc_auto/ba5770_abd8b88e8249406ebeee92f2f04e8491~mv2.png)
Methods:
![](https://static.wixstatic.com/media/ba5770_e02c5a134c5c4e36b242bb8490c0a42f~mv2.png/v1/fill/w_49,h_39,al_c,q_85,usm_0.66_1.00_0.01,blur_2,enc_auto/ba5770_e02c5a134c5c4e36b242bb8490c0a42f~mv2.png)
I don't think you can use this NPM because it needs to manipulate the DOM. You can use this NPM if you use a custom element.
Try adding something to the end of your text element so that it returns a string.
Something like this -
var app= $w('#text9').text