Home > Web Front-end > JS Tutorial > body text

JavaScript sets styles through the ID and name of the element_javascript tips

PHP中文网
Release: 2016-05-16 16:42:16
Original
1625 people have browsed it

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")
Copy after login

(2) Based on the tag in the parameter, return Reference or node to a set of elements

document.getElementsByTagName("td")
Copy after login

2. Implementation source code

 
 
 
 
JavaScript通过ID和name设置样式 
 
 
 

 
工号 姓名 年龄 性别
2012010101 张三三 23
2012010102 柳丝丝 20
Copy after login


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)!


source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!