If you're looking to change the style only temporarily during a click, you can achieve it using CSS like this:
#myElement:active{
/*Code Here*/
}
However, if you want the style to persist after the click event, JavaScript would be more suitable. For example:
HTML
<button onclick="myFunction()">Click Me</button>
JavaScript
function myFunction(){
document.getElementById('myElement').style.gridTemplateColumns = "auto auto auto"
}
Here's a Functional Example
function changeGrid(){
document.getElementById("grid").style.gridTemplateColumns = "auto auto auto"
}
#grid{
display: grid;
grid-template-columns: auto auto;
}
<button onclick="changeGrid()">Change Grid</button>;
<div id="grid">
<div>
hi
</div>
<div>
hello
</div>
<div>
yello
</div>
<div>
hey
</div>
<div>
wassup
</div>
<div>
yo
</div>
</div>