<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<title>test </title>
<style type="text/css">#square {
width: 100px;
height: 100px;
background: blue;
} #parallelogram{
width:100px;
height:70px;
background:blue;
-webkit-transform:skew(20deg);
-moz-transform:skew(20deg);
-o-transform:skew(20deg);
transform:skew(20deg);
}#parallelogram2{
width:100px;
height:70px;
background:blue;
-webkit-transform:skew(-20deg);
-moz-transform:skew(-20deg);
-o-transform:skew(-20deg);
transform:skew(-20deg);
}
</style>
</head>
<body>
<div id="wraper">
<div class="main">
<ul>
<li><div id ="square"class ="box">parallelogram</div></li>
<li><div id ="parallelogram"class ="box">parallelogram</div></li>
<li><div id ="parallelogram2"class ="box">parallelogram2</div></li>
</ul>
</div>
<textarea name="show" id="show" cols="30" rows="10"></textarea>
<script type="text/javascript" src=" http://code.jquery.com/jquery-1.5.2.min.js"></script>
<script type="text/javascript">
$(".box").click(function(){
var id = $(this).parents().attr('id');
var cssrules = document.styleSheets[0].rules["id"].style.cssText;
$("#show").html("cssrules"); });
</script>
</html>
</body>点击.box 时,在 textarea 中显示其 id ="square" (……)的css代码?外链css呢?
解决方案 »
- 用javascript切换两张图片
- 求助解决字符串问题
- 请问这段代码是什么意思?.add
- 请教:有几个文本框,怎样在输入特定长度的字符后自动将焦点移到下一个文本框?
- 怎么把input中的内容向上对齐?!
- 请教一下,下面这个应用js怎么写啊...急啊...
- 如何让<div>里的滚动条移动到最下方?
- 我在web有一个JS菜单,现在我在傍边放了flash,然后菜单被挡住了,怎么解决?
- 帮忙看看,strvalue后面怎么写
- 大家好,请帮忙解决这样一个问题,就是关于弹出窗口的!!!!!
- 不知道现在的技术是否可以实现啊~我有个页面1~上有个功能1
- 顶呀,怎样实现jQuery从右向左展开DIV(动画效果)???
$(".box").click(function(){
var ss = document.styleSheets[0];
var rules = ss.rules || ss.cssRules;
var rule = rules[$(this).parent().index()];
$("#show").html(rule.style.cssText.toLowerCase());
}); 参考:http://www.cnblogs.com/jikey/archive/2011/06/15/2082171.html
当然,cssText属性也是
可能不是所有浏览器支持
window.onload=function(){
document.getElementById("square").style.cssText="width:100px;height:100px; background:blue; ";
$(".box").click(function(){
console.log(this.style.cssText);
$("#show").text(this.style.cssText);
}); }
</script>
比如:
class = "box "
你说到底是box 还是box+空格 呢?