Home >Web Front-end >JS Tutorial >JavaScript sets styles through the ID and name of the element_javascript tips
This article mainly introduces JavaScript to set the style of the element through its ID and name. There is a good example below. Interested friends can test it
1. Description
( 1) Based on the id value of the provided element, return a reference or node to the element
document.getElementById("tr_th")
(2) Based on the tag in the parameter, return Reference or node to a set of elements
document.getElementsByTagName("td")
2. Implementation source code
JavaScript通过ID和name设置样式
工号 | 姓名 | 年龄 | 性别 |
---|---|---|---|
2012010101 | 张三三 | 23 | 男 |
2012010102 | 柳丝丝 | 20 | 女 |
3. Implementation results
(1) During initialization
(2) Click the "Set Color" button
The above is the content of JavaScript setting style through the ID and name of the element_javascript skills. For more related content, please pay attention to the PHP Chinese website (www.php.cn)!