Is there a way to dynamically freeze columns in a table as I scroll it horizontally? I've achieved this statically using JavaScript, but is there a way to indicate the number of columns and achieve the desired style?
This is what my JavaScript code currently looks like:
var styles =`
// CSS styles for freezing first two columns in a table
`;
// Dynamically create and append a <style> element with the specified styles
var styleSheet = document.createElement("style")
styleSheet.innerText = styles
document.head.appendChild(styleSheet)
Instead of manually adding nth-child every time, is it possible to automate this process with a JavaScript function?