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的应用方法
  • 热门搜索
    拉肚子可以喝牛奶吗 浙江工业大学之江学院怎么样 呼伦贝尔旅游景点 碧欧泉护肤品怎么样 三门峡旅游景点大全 鸡蛋和牛奶可以一起吃吗 旅游攻略网 粉刺怎么办 凉拌花生米 四点水怎么打