jQuery,hide()和show()无效!!!

LastingG 2014-07-25 03:48:01
直接贴码!

function hideBtn(index){
$('.order-status').eq(index).show('fast');
$('.receive-status').eq(index).hide('fast');
$('.btn02').eq(index).hide('fast');
$('.btn01').eq(index).hide('fast');
}
$(function(){
$('.btn02').click(function(){
var index = $('.btn02').index(this);
var orderId = $('.orderId').eq(index).val();
$.ajax({
type: "post", //以post方式与后台沟通
url : "orderAct!cancelOrder.action", //与此Action沟通
data: 'order.orderId='+orderId,
success: function(msg){//如果调用成功
if(msg == "success"){
hideBtn(indx);
alert('订单取消成功!');
}
else{
alert(msg);
}
},
error: function(){
alert("操作不当!");
}
});
});


在Ajax调用成功,并且返回值为success时会隐藏和显示一些东西,可是这个地方没有隐藏也没有显示,而是直接弹出框提示“订单取消成功!”,我以为是我的函数没有调用成功,可是我把alert放到函数hideBtn()中,同样的结果。
...全文
879 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
hyjiacan 2014-07-25
  • 打赏
  • 举报
回复
同学,hideBtn(indx); index indx 是这个问题吗?
Null_Reference 2014-07-25
  • 打赏
  • 举报
回复
进hideBtn(index) 这个函数了么?
LastingG 2014-07-25
  • 打赏
  • 举报
回复
要控制的控件如下:

<span class="order-status" 
								<c:if test="${order.orderState ne 0 }">
									style="display: none;"
								</c:if>
							>已取消
							</span>
		                    <span class="receive-status"
								<c:if test="${order.receiveState ne 0 }">
		                    		style="display: none;"
								</c:if>
		                    >未支付</span>
还有

<button class="btn01"
								<c:if test="${order.receiveState ne 0 || order.orderState ne 1 }">
									style="display: none;"							
								</c:if>
							>
								支付
							</button>
							<button class="btn02"
								<c:if test="${order.receiveState ne 0 || order.orderState ne 1 }">
									style="display: none;"							
								</c:if>
							>
								取消
							</button>

87,996

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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