1

I want to select a grid item and target the grid-column style that I have in my CSS. I want to actively change it using javascript but I have no idea how to select it with the DOM.

I figured I could use something like

document.querySelector('.className').style.grid-column = '1 / 2';

but that hasn't worked.

djvg
  • 11,722
  • 5
  • 72
  • 103
Accurac
  • 29
  • 1

1 Answers1

0

As explained here, you could try something like this:

document.querySelector('.className[style*="grid-column: 1 / 2"]');

However, it's a fragile solution.

djvg
  • 11,722
  • 5
  • 72
  • 103