0

my current css looks like this for class "firstTri"

.firstTri{
    width: 0; 
    height: 0; 
    border-top: 160px solid transparent;
    border-bottom: 160px solid transparent;

    border-left: 160px solid gray;
}

I want to change the color of this triangle to yellow, so I have:

$('.firstTri').css("border-right","160px solid yellow");

which works but what if I want to update the color with the values in this array:

samples = [
        { 
        values : ["blue", "red", "green", "blue", "yellow"],
        },
        { 
        values : ["...etc"],
        }

];

I was thinking something like this:

 $('.firstTri').css("border-right","160px solid samples[i].values[j]");

i and j increment, i increments after j ends

For example, the second index is red, so that would be

samples[0].values[1] 
1
  • 3
    Sting concatenation -> $('.firstTri').css("border-right","160px solid " + samples[i].values[j]); Commented Apr 21, 2015 at 18:17

1 Answer 1

2

You are putting a string into the CSS value. It cannot contain variables. If you would write something like this

$('.firstTri').css("border-right","160px solid " + samples[i].values[j]);

It should work.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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.