jquery选择器

今天用jquery选择器动态的定位按钮,出现了只能定位到一组按钮的第一个,问题闹了好半天,终于解决了.

先上代码:

<#list returnMap.centers as centerList>
<#if (centerList_index < 10)>
<tr>
   <td>${centerList_index+1}</td>
   <td>${centerList.handle!}</td>
   <td>${centerList.date?string("yyyy-MM-dd")!}</td>
   <td>${centerList.fromhospital!}</td>
   <td>${centerList.department!}</td>
   <td>${centerList.tohospital!}</td>
   <td>${centerList.todepartment!}</td>
   <td>${centerList.validtime!}天</td>
   <td>
    <#if centerList.pstatus=="0">
<input type="button" disabled="true" id="${centerList.id}" name="chakan" value="查看" οnclick="catchcase('${centerList.id}','${centerList.handle}','${centerList.fromhospital}','${centerList.department}');"/>
<input type="button" disabled="true" id="${centerList.id}" name="quxiao" value="已取消" οnclick="del('${centerList.id}','${centerList.handle}');"/>
<#else>
<input type="button" id="${centerList.id}" name="chakan" value="查看" οnclick="catchcase('${centerList.id}','${centerList.handle}','${centerList.fromhospital}','${centerList.department}');"/>
<input type="button" id="${centerList.id}" name="quxiao" value="取消" οnclick="del('${centerList.id}','${centerList.handle}');"/>
</#if>
</td>
</tr>
</#if>
</#list>
</table>
<#else>
未查到结果
</#if>
</div>
<div style="clear: both;"></div>
</div>
</div>
<script type="text/javascript">
// 点击查看按钮
function catchcase(cid,handle,hospital,department) {

location.href = "${request.contextPath}/caseListTr.action?cid="+cid+"&handle="+handle+"&fromhospital="+hospital+"&department="+department+"&page=1";
   
};

// 点击取消按钮
function del(cid,handle) {
$.ajax({
url:"${request.contextPath}/centerDelete.action?cid="+cid+"&handle="+handle,
type:"post",
success:function(data){
var json = eval("("+data+")");
if(json.success){
$("#"+cid+"[name='chakan']").attr("disabled",true);
$("#"+cid+"[name='quxiao']").attr("disabled",true);
$("#"+cid+"[name='quxiao']").val("已取消");

}
}
});
};

</script>

这样的,每组按钮只能定位到第一个按钮,后来查资料发现,id是唯一的,不能相同,所以把id换成了class就可以了,要记住教训!!!!!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值