日期:2014-05-17  浏览次数:20705 次

javascript调用css文件

《html文件》内容如下:

?

<html>

<head>

<title>无标题文档</title>

<script>

function changecss(){

var css=document.createElement('link');

css.href='123.css';

css.rel="stylesheet";

css.type="text/css";

document.body.appendChild(css);

}

window.onload=function(){

//document.getElementById('changecss').onclick=changecss;

?

? changecss();

}

</script>

</head>

?

<body>

<a href="#" class="tt"> 接口即可连接空间看</a><br />

<a href="#" class="t">oridfgdfs gdfgdfgtpoier</a><br />

<a href="#" >dfg</a>

</body>

</html>

?

?

《123.css》 内容如下:

?

a{

color:#666666;

font-size:12px;

text-decoration:none;}

a:hover{

color:#0000FF;

font-size:12px;

text-decoration:underline;}