-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"?

asked Jul 14, 2013 at 6:50
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(',');
answered Jul 14, 2013 at 6:51
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(", ");
answered Jul 14, 2013 at 6:52

Comments

-1

This is what you are looking for:

var myArray = new Array("Red","Blue");
answered Jul 14, 2013 at 6:56

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.