1

I can see the property grid-template-areas inside the style object:

document.getElementById("elem-id").style

i tried setting it via :

js directly

document.getElementById("elem-id").style.gridTemplateAreas = "a a b"

jquery

$("#elem-id").css({"grid-template-areas":"a b c"})

but nothing seems to work, the property remains empty.

1 Answer 1

3

Setting Template Areas like that will require nested quotes. It needs one set of quotes for the overall JavaScript string, and within that, it needs a pair of quotes to denote each set of row cells in the styling.

The actual column and row declarations have not been provided. But anyway one of the following should work, depending on whether you have declared a single row of 3 cells, or 3 rows of 1 cell each:

document.getElementById("elem-id").style.gridTemplateAreas = "'a a b'";

Or:

document.getElementById("elem-id").style.gridTemplateAreas = "'a' 'a' 'b'";
Sign up to request clarification or add additional context in comments.

1 Comment

works great ! i only needed a single row, weird no error message is prompt when invalid format is given

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.