FlyCat

方法一:给link一个id,直接获取该DOM操作href

<link rel="stylesheet"  id="stylelink" type="text/css"/>

<a href="#" onclick=\'javascript:document.getElementById("stylelink").href = "blue.css";return false;\'>1111</a>
<a href="#" onclick=\'javascript:document.getElementById("stylelink").href = "red.css";return false;\'>1111</a>

方法二:

 <!DOCTYPE html>
<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" >
<title>无标题 1</title>
<link rel="alternate stylesheet" href="red.css" type="text/css" title="red" media="screen, projection"/>
<link rel="alternate stylesheet" href="blue.css" type="text/css" title="blue" media="screen, projection"/>

<script type="text/javascript">
    function setActiveStyleSheet(title) {
        var i, a, main;
        if (title) {
            for (i = 0; (a = document.getElementsByTagName(\'link\')[i]); i++) {
                if (a.getAttribute(\'rel\').indexOf(\'style\') != -1 && a.getAttribute(\'title\')) {
                    a.disabled = true;
                    if (a.getAttribute(\'title\') == title) 
                     a.disabled = false;
                }
            }
        }
    }
</script>
</head>

<body>
<a href="#" onclick="setActiveStyleSheet(\'red\'); return false;" >red</a>
<a href="#" onclick="setActiveStyleSheet(\'blue\'); return false;" >blue</a>
<a href="#" onclick="setActiveStyleSheet(\'none\'); return false;">none</a>
</body>
</html>

 

分类:

技术点:

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-01
  • 2018-08-16
  • 2022-03-05
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-11-26
  • 2022-03-10
  • 2022-12-23
  • 2021-09-17
  • 2022-02-21
相关资源
相似解决方案