js部分
/图片预览
$('.popup').hide()
//弹框隐藏
$('.content img').click(function(e){
//向图片元素绑定事件
console.error(1);
$('.popup').html(`<div class="popup"><img src="${e.currentTarget.src}" alt=""></div>`)
//渲染到页面
$('.popup').show()
$('.shadessk').show()
document.body.style.overflow='hidden'
// $('.popup').show()
})
// 确认事件
function cod(){
$('.shadessk').hide()
$('.popup').hide()
sessionStorage.removeItem('ber')
}
Event 对象代表事件的状态,比如事件在其中发生的元素、键盘按键的状态、鼠标的位置、鼠标按钮的状态。
currentTarget
和 target
是监听特定事件时事件对象的属性
element.addEventListener('click', function (e) {
// currentTarget 和 target 是 e 的属性
console.log(e.currentTarget)
console.log(e.target)
})
区别
currentTarget
是事件绑定到的元素。它永远不会改变。在上面的示例代码中,e.currentTarget
是元素。
在单击事件的情况下,目标是用户单击的元素。它可以是原始元素或其任何子元素,具体取决于用户单击的位置