-1

I create a variable from a title attribute tile="Red, Blue". Is there a simple way to make this an array. So the array has 2 values "Red" & "Blue"?

1

3 Answers 3

0

You can create an array as :

var title = "Red, Blue";
var array = tile.split(',');

OR ,

var array1 = document.getElementById('yourElementID')
                      .getAttribute('tile').split(',');
Sign up to request clarification or add additional context in comments.

Comments

-1

Do you mean splitting string?

var title = "Red, Blue";
var titleArray = title.split(", ");

Comments

-1

This is what you are looking for:

var myArray = new Array("Red","Blue");

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.