簡而言之,我不知道為什么它不起作用,我嘗試了Console.Log()來弄清楚“這”是什么,并且該事件一直在傳遞窗口。這是一個單擊事件,旨在激活該輪播中某個人物的效果,這就是為什么我不能僅僅單獨搜索課程(至少據我所知)的原因。更聰明的解決方案嗎?var carFigure = null;//----------The Events$('.figure').click(toggleCarousel(this));//$('.figure').mouseover(stopCarousel(this));//$('.figure').mouseleave(startCarousel(carFigure));//------------Switcharoo functionfunction toggleCarousel(event) { var bool = false; console.log(event) if (bool) { stopCarousel(event); bool = false; } else { startCarousel(event); bool = true; }}//----------The action functionsfunction stopCarousel(e) {if (carFigure != null) { document.getElementById('carousel').style.animationPlayState = "paused"; var p = e.parentElement; var a = p.getElementsByTagName('DIV')[2]; if (a.getElementsByTagName('IMG')[0].style.transform = "none") { a.getElementsByTagName('IMG')[0].style.transform = "scale(1.2, 1.2) translateY(-25%)"; a.getElementsByTagName('IMG')[0].style.borderRadius = "100%"; a.getElementsByTagName('H5')[0].style.color = "rgba(255,255,255, 0)"; this.getElementsByClassName('links')[0].style.transform = "translateY(-250%)"; this.getElementsByClassName('links')[0].style.opacity = "1"; carFigure = null; } }};function startCarousel(e) { if (e != null) { carFigure = e; document.getElementById('carousel').style.animationPlayState = "running"; var p = e.parentElement; var a = p.getElementsByTagName('DIV')[2]; a.getElementsByTagName('IMG')[0].style.transform = "none"; a.getElementsByTagName('IMG')[0].style.borderRadius = "0"; a.getElementsByTagName('H5')[0].style.color = "rgba(255,255,255, 1)"; this.getElementsByClassName('links')[0].style.transform = "none"; this.getElementsByClassName('links')[0].style.opacity = "0"; }};
“此”在另一事件中無法正常工作。我對為什么一無所知
慕田峪4524236
2019-11-21 09:48:05