cforeach遍历出来的值放到div中 点击事件从div中取值
$(function(){$('.Caddress.add_mi').click(function(){$(this).css('background','url("be...
$(function() {
$('.Caddress .add_mi').click(function() {
$(this).css('background','url("beforStyle/image/mail_1.jpg") no-repeat').siblings('.add_mi').css('background', 'url("mail.jpg") no-repeat')
$("#addres").val($(".toAddress").html());
})
})
<c:forEach items="${selAddress}" var="map">
<div class="add_mi">
<p class="toAddress" style="border-bottom:1px dashed #ccc;line-height:20px;">${map.aid} ${map.province } ${map.city } ${map.area } ${map.detailadress } (${map.dresname}收) ${map.postcode} ${map.phone}</p>
<p style="padding-top:5px;"><a href="beforUser/toUpaddress?aid=${map.aid}"><input type="button" value="编辑"></a> <a href="beforUser/deleteAddress?aid=${map.aid}"><input type="button" value="删除"></a></p>
</div>
</c:forEach> 展开
$('.Caddress .add_mi').click(function() {
$(this).css('background','url("beforStyle/image/mail_1.jpg") no-repeat').siblings('.add_mi').css('background', 'url("mail.jpg") no-repeat')
$("#addres").val($(".toAddress").html());
})
})
<c:forEach items="${selAddress}" var="map">
<div class="add_mi">
<p class="toAddress" style="border-bottom:1px dashed #ccc;line-height:20px;">${map.aid} ${map.province } ${map.city } ${map.area } ${map.detailadress } (${map.dresname}收) ${map.postcode} ${map.phone}</p>
<p style="padding-top:5px;"><a href="beforUser/toUpaddress?aid=${map.aid}"><input type="button" value="编辑"></a> <a href="beforUser/deleteAddress?aid=${map.aid}"><input type="button" value="删除"></a></p>
</div>
</c:forEach> 展开
展开全部
$(function() {
$('.Caddress .add_mi').click(function() {
var _this = $(this);
var address = _this.find(".toAddress").text(); // 这里最好是使用text()比较安全
_this.css('background','url("beforStyle/image/mail_1.jpg") no-repeat')
.siblings('.add_mi')
.css('background', 'url("mail.jpg") no-repeat');
$("#addres").val(address);
})
});
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询