js获取外联样式

作者:暴躁小n | 创建时间: 2023-04-09
外联js样式用法...
js获取外联样式

操作方法

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

使用window.getComputedStyle('')

window也可以去掉

点击展开全文

更多推荐