开发者

If statement does't change background image

The if statement gives me the correct information for swipeDirection and swipeLength and I've obtained both the results of the IF and the ELSE except for the image changing.

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 + '&deg;' + '<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" + 'Star开发者_运维技巧t H:' + startX + ' V:' + startY + '<br>' +  ' End H:' + curX + ' V:' + curY  + '<br>' + "Swipe Length: " + swipeLength + '<br>' + 'Swipe Angle: ' + swipeAngle + '&deg;' + '<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';


Try .backgroundImage (NB: capital "i")


The property is backgroundImage not backgroundimage, and the syntax of a URL in CSS is url(railroadtracks.png) not just railroadtracks.png


You're assigning (=) instead of comparing (==) here:

if ( (swipeDirection = 'down') && (swipeLength >= 180) ) {


Did you mean to do swipeDirection = 'down' instead of swipeDirection == 'down'?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜