我这个小啄: http://jsfiddle.net/7hqyq/jQuery的褪色内容+ DIV变化
而且因为我是新来的jQuery,我想知道如何更改选定方的背景颜色(因此的第一个广场上加载页面)。以及如何淡入/淡出细节div的内容文本。
在此先感谢;)
HTML:
<div class="square" contentId="c1"></div>
<div class="square" contentId="c2"></div>
<div class="square" contentId="c3"></div>
<div class="square" contentId="c4"></div>
<div id="details">Content for div 1</div>
<div style="display: none" id="c1"> Content for div 1</div>
<div style="display: none" id="c2"> Content for div 2</div>
<div style="display: none" id="c3"> Content for div 3</div>
<div style="display: none" id="c4"> Content for div 4</div>
CSS:
.square{
width: 80px;
height: 80px;
margin: 10px;
float: left;
background: #CCC;
}
#details{
width: 380px;
height: 100px;
margin: 10px;
float: left;
background: #999;
}
的jQuery:
$(".square").on("click", function() {
var id= $(this).attr("contentId");
$("#details").html($("#" + id).html());
});
'contentId'是无效的属性,使用'数据内容识别= “”'(!小写) –