if语句为swipeDirection和swipeLength提供了正确的信息,除了图像更改外,我还获得了IF和ELSE的结果。
if ( (swipeDirection = 'down') && (swipeLength >= 180) ) {
touchEnabledElement.style.backgroundimage = 'railroadtracks.png';
document.getElementById('message').innerHTML = "IF" + 'Start H:' + startX + ' V:' + startY + '<br>' + ' End H:' + curX + ' V:' + curY + '<br>' + "Swipe Length: " + swipeLength + '<br>' + 'Swipe Angle: ' + swipeAngle + '°' + '<br>' + 'Swipe Direction: ' + swipeDirection + '<br><br><span style="font-size:.5em;">(Please wait for green screen before swiping again)<\/span>';
} else {
document.getElementById('message').innerHTML = "ELSE" + 'Start H:' + startX + ' V:' + startY + '<br>' + ' End H:' + curX + ' V:' + curY + '<br>' + "Swipe Length: " + swipeLength + '<br>' + 'Swipe Angle: ' + swipeAngle + '°' + '<br>' + 'Swipe Direction: ' + swipeDirection + '<br><br><span style="font-size:.5em;">(Please wait for green screen before swiping again)<\/span>';
touchEnabledElement.style.backgroundimage = 'railroadtracks2.png';
答案 0 :(得分:1)
尝试.backgroundImage
(注意:资本“我”)
答案 1 :(得分:1)
该属性为backgroundImage
而非backgroundimage
,CSS中的网址语法为url(railroadtracks.png)
,而不仅仅是railroadtracks.png
答案 2 :(得分:1)
你在这里分配(=)而不是比较(==):
if ( (swipeDirection = 'down') && (swipeLength >= 180) ) {
答案 3 :(得分:0)
您的意思是swipeDirection = 'down'
代替swipeDirection == 'down'
吗?