Target object in JavaScript array and add class

56 Views Asked by At

Currently I am using annotorious.js to get text annotation. Using the documentation, I am able to log "x" amount of array.

I am trying to access every "text" object from every array, either to get it to show up in a textbox or be able to add a class to it so I can css style it.

My main goal is to get every text from the array to show in the browser at once.

const annotations = anno.getAnnotations();

console.log(annotations);

Enter image description here

1

There are 1 best solutions below

1
On

Run a loop and push all the text values in "x" array.

const annotations = anno.getAnnotations();
var x = [];

for (var i = 0; i < annotations.length; i++) {
    x.push(annotations[i]["text"]);
}

console.log(x);