换肤的时候点第二个按钮改变样式,再点第一个就不可以了

<!DOCTYPE html>

<html>


<head>

<meta charset="UTF-8">

<title></title>

<link id="css1" rel="stylesheet" type="text/css" href="css1.css" />

<script type="text/javascript">

window.onload=function(){

var  a=document.getElementById("a");

var b=document.getElementById("b");

a.onlock=function () {

var c= document.getElementById("css1")

c[href] = "css1.css"

}

            b.onclick=function () {

var d = document.getElementById("css1")

d.href = "css2.css"

}

}

</script>

</head>


<body>

<input type="button" name="" id="a" value="红色"  />

<input type="button" name="" id="b" value="蓝色"/>

</body>


</html>


Youruncle
浏览 1436回答 2
2回答

潮流229078

你的标签都错了,【onlock】是什么方法 写错了吧,a.onclick=function () {   var c= document.getElementById("css1")   c.href = "css/1.css"}b.onclick=function () {   var d = document.getElementById("css1")   d.href = "css/2.css"}

Danny_V

  c[href] = "css1.css"d.href = "css2.css"效果一样吗?
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript