我在彈出窗口中顯示用戶單擊的最後一個元素而不是當前元素時出現問題。我有幾個不同的優惠券,用戶可以點擊打印。例如,如果用戶點擊具有「測試」標識的優惠券,則什麼都不會發生,但是當用戶第二次點擊時,優惠券出現。在這種情況下,無論點擊哪張優惠券,「測試優惠券」都會繼續出現。如果手動刷新頁面,則用戶可以點擊新的優惠券。我究竟做錯了什麼?帶彈出窗口的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