今天写了个动态切换样式文件,感觉比我之前做的那个好多了哦。
2012-06-12 17:03
357 查看
/Files/Silvia/css_change.rar
页面代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<link rel="stylesheet" href="red.css" id="lf"/></link>
</head>
<script>
function abc(obj)
{
var linkfile=document.getElementById('lf');
var c=obj.selectedIndex;
if(c==1) linkfile.href='red.css';
else if(c==2) linkfile.href='green.css';
else linkfile.href='yellow.css';
}
</script>
<body>
<div></div>
<select id="selCss" onchange="abc(this)">
<option value="0">请选择颜色</option>
<option value="1">红色</option>
<option value="2">绿色</option>
<option value="3">黄色</option>
</select>
</body>
</html>
页面代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<link rel="stylesheet" href="red.css" id="lf"/></link>
</head>
<script>
function abc(obj)
{
var linkfile=document.getElementById('lf');
var c=obj.selectedIndex;
if(c==1) linkfile.href='red.css';
else if(c==2) linkfile.href='green.css';
else linkfile.href='yellow.css';
}
</script>
<body>
<div></div>
<select id="selCss" onchange="abc(this)">
<option value="0">请选择颜色</option>
<option value="1">红色</option>
<option value="2">绿色</option>
<option value="3">黄色</option>
</select>
</body>
</html>
相关文章推荐
- javascript实现css主题样式切换;动态改变引入的css文件;
- AngularJS动态切换样式
- PDF文件预览 jquery.media.js动态切换
- Style样式的四种使用(包括用C#代码动态加载资源文件并设置样式)
- AngularJS实现动态切换样式的方法分析
- flex 学习笔记 动态改变 样式文件
- WPF后台动态调用样式文件,不用来回改App.g.cs
- 动态加载样式(css)文件
- android 动态设置横竖屏切换 控制dialog等布局文件加载的方法
- WPF后台动态调用样式文件
- Yii - 布局文件的动态切换
- WPF后台动态调用样式文件
- linux使用php动态安装模块mysqli.so(ext/mysqlnd/mysqlnd.h: 没有那个文件或目录)
- 动态加载样式(css)文件
- Asp.net换肤,动态切换Css文件形式
- WPF后台动态调用样式文件
- DataGrid应用样式文件定义动态样式
- FLEX中实现动态样式切换例子
- 学习笔记之——RadioButton在XML文件便可实现点击切换样式
- web风格样式动态切换并cookie记忆