To freeze the row/column we can use a simple HTML table and CSS. HTML: In HTML we can define the header row by <th> tag or we can use <td> tag also. Below example is using the <th> tag. We also put the table in DIV element to see the horizontal and vertical scrollbar by setting the overflow property of the DIV element.
HTML attributes have the following features: Their name is case-insensitive ( id is same as ID ). Their values are always strings.
To make an object immutable, recursively freeze each property which is of type object (deep freeze). Use the pattern on a case-by-case basis based on your design when you know the object contains no cycles in the reference graph, otherwise an endless loop will be triggered.
We can use two approaches to modify an attribute of an HTML element using JavaScript. Approach 1: We can use the inbuilt setAttribute() function of JavaScript.
If I want to make a javascript object's properties immutable, I can use Object methods such as defineProperties()
, defineProperty()
, and freeze()
. My question is, how can I do the same with HTML element attributes?
I've already tried the aforementioned methods, and while they can be used to prevent an element's properties from being set directly (e.g. elem.id = 'foo';
), as expected, the underlying attributes can still be changed via setAttribute()
.
An answer of "no, it's not possible" would be acceptable, but I haven't come across any definitive statement to that effect yet.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With