Jquery瀑布流中 如何取出Left都为0的div 并修改class="left z"
<divid="feed_div"><divclass="item"style="display:block;position:absolute;top:0px;left...
<div id="feed_div">
<div class="item" style="display: block; position: absolute; top: 0px; left: 0px;">...</div>
<div class="item" style="display: block; position: absolute; top: 0px; left: 620px;">...</div>
<div class="item" style="display: block; position: absolute; top: 183px; left: 0px;">...</div>
<div class="item" style="display: block; position: absolute; top: 437px; left: 620px;">...</div>
....
<div class="item" style="display: block; position: absolute; top: 807px; left: 0px;">...</div>
</div> 展开
<div class="item" style="display: block; position: absolute; top: 0px; left: 0px;">...</div>
<div class="item" style="display: block; position: absolute; top: 0px; left: 620px;">...</div>
<div class="item" style="display: block; position: absolute; top: 183px; left: 0px;">...</div>
<div class="item" style="display: block; position: absolute; top: 437px; left: 620px;">...</div>
....
<div class="item" style="display: block; position: absolute; top: 807px; left: 0px;">...</div>
</div> 展开
2个回答
展开全部
如下Jquery可以实现:
$(document).ready(function(){
$("#feed_div").find("div").each(function(){ //feed_div里的所有div
if(this.style.left == "0px"){ //这里面是left为0px的div
$(this).attr("class", "left z"); //这里修改class为left z
}
});
alert($("#feed_div").html()); //弹出结果
});
展开全部
<html>
<head>
<script src="http://code.jquery.com/jquery-1.8.2.min.js" type="text/javascript"></script>
<script>
$(document).ready(function(){
$(".item").each(function(){
var leftVal=$(this).css("left");
if(leftVal=="0px")
{
$(this).attr("class","left z");
}
});
});
</script>
</head>
<body>
<div id="feed_div">
<div class="item" style="display: block; position: absolute; top: 0px; left: 0px;">...</div>
<div class="item" style="display: block; position: absolute; top: 0px; left: 620px;">...</div>
<div class="item" style="display: block; position: absolute; top: 183px; left: 0px;">...</div>
<div class="item" style="display: block; position: absolute; top: 437px; left: 620px;">...</div>
<div class="item" style="display: block; position: absolute; top: 807px; left: 0px;">...</div>
</div>
</body>
试试看,随手写的= =
<head>
<script src="http://code.jquery.com/jquery-1.8.2.min.js" type="text/javascript"></script>
<script>
$(document).ready(function(){
$(".item").each(function(){
var leftVal=$(this).css("left");
if(leftVal=="0px")
{
$(this).attr("class","left z");
}
});
});
</script>
</head>
<body>
<div id="feed_div">
<div class="item" style="display: block; position: absolute; top: 0px; left: 0px;">...</div>
<div class="item" style="display: block; position: absolute; top: 0px; left: 620px;">...</div>
<div class="item" style="display: block; position: absolute; top: 183px; left: 0px;">...</div>
<div class="item" style="display: block; position: absolute; top: 437px; left: 620px;">...</div>
<div class="item" style="display: block; position: absolute; top: 807px; left: 0px;">...</div>
</div>
</body>
试试看,随手写的= =
追问
只有第一次载入的时候成功 再刷新则又返回ckass=item了
追答
。。。刷新相当于页面重新载入当然会变回class=item啊。。
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询