Javascript获取标签ID改变style属性的代码_javascript技巧

WBOY
Release: 2016-05-16 17:50:27
Original
1439 people have browsed it

实例JavaScript代码
下面的这段代码中,我们通过select元素的name属性来设置具体要访问style的哪个属性(本例中为背景色),这样,这个函数就可以用来设置不同的CSS属性了。

复制代码代码如下:



HTML代码
本例的HTML代码比较简单,一个select元素用来罗列出来可选的背景色。而按钮则负责触发事件,调用函数。
复制代码代码如下:





效果
选择颜色后点击按钮“设置背景颜色”。

[Ctrl+A 全选 注: 如需引入外部Js需刷新才能执行]
Related labels:
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
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!