CODEPEN例 http://codepen.io/dada78/pen/b50de869b75b32e220956bb36052733b如何在這種情況下使變量全局可訪問?
我試圖找出如何使在codepen我在我的功能「fadeOutUnselected(notThisId)」訪問highlightSelection功能使用第40行的selectedId變量?
function fadeOutUnselected(notThisId) {
var tl = new TimelineMax();
tl.to(".options:not([id=" + notThisId +"]), input[type='radio']", 0.5, {autoAlpha:0}, "getSlidesReady+=4") //fade out all options but the selected one
//.to("#"+ selectedId, 0.5, {y:0}) //animate selectedId option up
.set(".options:not([id=" + notThisId +"]), input[type='radio']", {y:0})
return tl;
}
任何幫助表示讚賞。我想要做的只是將用戶選擇的選項(「selectedId」變量)設置爲位置y:0。
謝謝!
嘗試宣告它在最頂端,你的比例接近,然後在hightlightSelection功能只是修改它,這樣它在全球上市。 –
感謝Caleb,我試着把它加到頂部,正好在百分比變量的下面:'var selectedId =「option-」+ label.getAttribute(「for」)。slice(-1); '並且在highlightSelection函數內部,我只是添加了'var tl = new TimelineMax();'但我仍然無法使它工作...... :-( – user2163224