展开全部
用JS
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<TITLE>无刷新变换样式表</TITLE>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<link href="style/css1.css" rel="stylesheet" type="text/css" id="css">
</HEAD>
<script type="text/javascript">
function change(a){
var css=document.getElementById("css");
if (a==1)
css.setAttribute("href","style/css1.css");
if (a==2)
css.setAttribute("href","style/css2.css");
if (a==3)
css.setAttribute("href","style/css3.css");
}
</script>
<BODY>
<div id="chs">
<a href="#" onClick="change(1)">使用样式表1</a>
<a href="#" onClick="change(2)">使用样式表2</a>
<a href="#" onClick="change(3)">使用样式表3</a><br />换了样式表
</div>
</BODY>
</HTML>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<TITLE>无刷新变换样式表</TITLE>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<link href="style/css1.css" rel="stylesheet" type="text/css" id="css">
</HEAD>
<script type="text/javascript">
function change(a){
var css=document.getElementById("css");
if (a==1)
css.setAttribute("href","style/css1.css");
if (a==2)
css.setAttribute("href","style/css2.css");
if (a==3)
css.setAttribute("href","style/css3.css");
}
</script>
<BODY>
<div id="chs">
<a href="#" onClick="change(1)">使用样式表1</a>
<a href="#" onClick="change(2)">使用样式表2</a>
<a href="#" onClick="change(3)">使用样式表3</a><br />换了样式表
</div>
</BODY>
</HTML>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询