each循环

Specialaspnet 2011-09-17 05:46:29
结构


<table id="dtlWorksList" class="tasklist" cellspacing="0" border="0" style="border-collapse:collapse;">
<tr>
<td>
<table width="590" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#eeeeee">
<tr>

<td width="590" valign="top" bgcolor="#FFFFFF">
<table width="590" border="0" cellspacing="0" cellpadding="3">
<tr>
<td width="590" height="25" class="linebotxx2">
<table width="560" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="420">
任务已浏览 <span class="textbluec">投稿时间:</span><span class="textred">2011-9-17 11:43:00</span></td>
<td width="140" style="float:right; margin-right:0px; vertical-align:middle">
<a id="tongguo" href="javascript:Awards(3,31)">审核通过</a>  <a id="butongguo" href="javascript:NotAwards(3,31)">审核不通过</a>

</td>
</tr>
</table>
</td>
</tr>
</table>
<div class="blank10">
</div>
<table width="560" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td class="bground" style="background: url(../images/weike/hege.gif) no-repeat top 90%; height:100px;">

完成

<br />

<br />
</td>

</tr>
</table>

</td>
</tr>
</table>
<div style="height:10px;"></div>
</td>
</tr>
<tr>
<td>
<table width="590" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#eeeeee">
<tr>

<td width="590" valign="top" bgcolor="#FFFFFF">
<table width="590" border="0" cellspacing="0" cellpadding="3">
<tr>
<td width="590" height="25" class="linebotxx2">
<table width="560" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="420">
任务已浏览 <span class="textbluec">投稿时间:</span><span class="textred">2011-9-17 17:00:00</span></td>
<td width="140" style="float:right; margin-right:0px; vertical-align:middle">
<a id="tongguo" href="javascript:Awards(3,35)">审核通过</a>  <a id="butongguo" href="javascript:NotAwards(3,35)">审核不通过</a>

</td>
</tr>
</table>
</td>
</tr>
</table>
<div class="blank10">
</div>
<table width="560" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td class="bground" style="background: url(../images/weike/hege.gif) no-repeat top 90%; height:100px;">

qq

<br />

<br />
</td>

</tr>
</table>

</td>
</tr>
</table>
<div style="height:10px;"></div>
</td>
</tr>
</table>



<script type="text/javascript">
function() {
var bg = $(".bground").css("background");

if (bg = "background: url(../images/weike/daishenhe.gif) no-repeat top 90%; height:100px;") {
$("#tongguo").css({ "display": "block" });
$("#butongguo").css({ "display": "block" });
}
if (bg = "background: url(../images/weike/zhongbiao.gif) no-repeat top 90%; height:100px;") {
$("#tongguo").css({ "display": "block" });
$("#butongguo").css({ "display": "none" });
}
else {
$("#tongguo").css({ "display": "block" });
$("#butongguo").css({ "display": "none" });
}
}
</script>


这样的js只能改变绑定的第一行,所以我要循环所有的行请问怎么实现
...全文
111 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
ajaxtop 2011-09-17
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 dongxinxi 的回复:]
JScript code
$(function(){
$(".bground").each(function() {
var bg = $(this).css("background");
//后面不变..
});
});
[/Quote]
+1
a13086570439 2011-09-17
  • 打赏
  • 举报
回复
很简单,因为你在乱弄。。语法是这么用的
$.each($(".background"),function(i,item){ 执行语句 });
huangwenquan123 2011-09-17
  • 打赏
  • 举报
回复
$(document).ready(function(){
$(".bground").each(function(){
var bg=$(this).css("background");
//...
//你当中的if少了个=号
//为什么要判断background,直接判断backgroundImage省得写那么长。
})
})
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 specialaspnet 的回复:]
JScript code


<script type="text/javascript">
window.onload = function(){$(".tasklist tr .bground").each(function() {
alert("aa");
})};
</script>


我这样写都不会alert
[/Quote]
那个是事件调用的处理函数
  • 打赏
  • 举报
回复
$(function(){
$(".bground").each(function() {
var bg = $(this).css("background");
//后面不变..
});
});

shine_fly 2011-09-17
  • 打赏
  • 举报
回复
拿分闪人~~~
Specialaspnet 2011-09-17
  • 打赏
  • 举报
回复

<script type="text/javascript">
window.onload = $(".tasklist tr .bground").each(function() {
alert("aa");
})
</script>

我这样写都不会alert

62,074

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧