我在弹出窗口中显示用户单击的最后一个元素而不是当前元素时出现问题。我有几个不同的优惠券,用户可以点击打印。例如,如果用户点击具有“测试”标识的优惠券,则什么都不会发生,但是当用户第二次点击时,优惠券出现。在这种情况下,无论点击哪张优惠券,“测试优惠券”都会继续出现。如果手动刷新页面,则用户可以点击新的优惠券。我究竟做错了什么?带弹出窗口的jquery问题
$(".coupon").click(function() {
var id = $(this).attr("id");
$('.pop').popupWindow({
windowURL:'coupons/' + id + '.html'
});
});
.coupon {
margin:10px;
height:152px;
width:193px;
position:relative;
cursor:pointer;
float:left;
}
.coupon .price {
margin-top:7px;
font-size:29px;
font-weight:bold;
color:white;
text-align:center;
}
.coupon .title {
margin-top:5px;
font-size:18px;
font-weight:bold;
color:black;
text-align:center;
font-family:'Times New Roman',Georgia,Serif;
}
<div class="coupon pop" id="test1">
<div class="price">
$5.00 OFF
</div>
<div class="title">
Test
</div>
</div>
<div class="coupon pop" id="test2">
<div class="price">
$5.00 OFF
</div>
<div class="title">
Another test
</div>
</div>
什么popupWindow功能做什么?你使用任何插件? – Shyju
似乎基本上没问题。你可以发布你的其他代码或jsFiddle吗? – j08691
@Shyju,我使用这里的插件:http://www.swip.codylindley.com/popupWindowDemo.html – Muzz