Home  >  Article  >  Web Front-end  >  JS method to allow visitors to choose the text color of web pages by themselves_javascript skills

JS method to allow visitors to choose the text color of web pages by themselves_javascript skills

WBOY
WBOYOriginal
2016-05-16 16:13:261135browse

The example in this article describes the method of using JS to allow visitors to choose the text color of web pages by themselves. Share it with everyone for your reference. The specific implementation method is as follows:

<html>
<head>
<title>JS实现让访问者自助选择网页的文字颜色</title>
<script language="javascript">
<!--
 function chColor(c){
 document.body.style.color = c;
 }
//-->
</script>
</head>
<body>
<input name="c" type="radio" value="#000000" onClick="chColor(this.value)" checked>黑
<input name="c" type="radio" value="#0000FF" onClick="chColor(this.value)">蓝
<input name="c" type="radio" value="#FF0000" onClick="chColor(this.value)">红<br>
本行文字会改变颜色哦! 
</body>
</html>

I hope this article will be helpful to everyone’s JavaScript programming design.

Statement:
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