I am trying to use a JavaScript typewriter effect and WordPress is throwing me the following error (The value of attribute [ data-type ] must be in double quotes.) when adding the html into a custom html widget.

I have the code working on CodePen. However w hen I change the data-type to double quotes and the data inside to single quotes the code stops working.

Any suggestions/am I missing something?

Thanks in advanced.

1 Answer
1

change it to CSV

data-type="Information Gathering, Farming & Husbandry, Delivery Service, Emergency Response, Remote Inspections, Mapping & Surveying, Maritime Success, Military & Defense Support, Scientific Research, Real Time Surveillance "

then do

var toRotate = elements[i].getAttribute('data-type').split(", ");

the .split(", ") turns the CSV string into an array. then do

new TxtType(elements[i], toRotate, period);

the toRotate is passed into TxtType as-is, it’s not parsed by JSON anymore, just kept the array it is.

prepare for a mod to flag this as unrelated to wp

Leave a Reply

Your email address will not be published. Required fields are marked *