js获取外联样式

 时间:2026-04-28 13:40:09

1、<!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>

<script type="text/javascript">

        function changeBackgroundColor() {

                //这儿如何写访问外部样式表中代码(比如:.special中的border值)

        }

</script>

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

</head>

<body>

<div id="div1" class="special"></div>

<input type="button" value="Change Background Color" onclick="changeBackgroundColor()" />

</body>

</html>

2、使用window.getComputedStyle('')

3、window也可以去掉

  • CSS中有哪些常用选择器?
  • java编程:判断某年是否为闰年
  • CSS3教程 为元素添加圆角边框
  • css滤镜实现鼠标悬停图片变黑白(灰色)
  • navicat的应用方法
  • 热门搜索
    产后抑郁症怎么治疗 婴儿咳嗽怎么办 杨万里简介 变态游戏大全 i7处理器怎么样 公式编辑器怎么用 黔西南旅游景点大全 童话故事大全100字 游戏下载大全 怎么看电视直播