[Solved] javascript not working (if else ) [closed]


I assume you are trying to do this:

function run() {
  var image = document.getElementById('boy');
  if (image.src.match("emoji\walk")) {
    image.src = "https://stackoverflow.com/questions/37643551/emoji\run.png";
  } else {
    image.src = "https://stackoverflow.com/questions/37643551/emoji\walk.png";
  }
}

function m() {
  var image = document.getElementById('moon');

  if (image.src.match("emoji\1.png")) {
    image.src = "emoji\2.png";
  } else if (image.src.match("emoji\2.png")) {
    image.src = "emoji\3.png";
  } else if (image.src.match("emoji\3.png")) {
    image.src = "emoji\4.png";
  } else if (image.src.match("emoji\4.png")) {
    image.src = "emoji\5.png";
  } else if (image.src.match("emoji\5.png")) {
    image.src = "emoji\6.png";
  } else if (image.src.match("emoji\6.png")) {
    image.src = "emoji\7.png";
  } else if (image.src.match("emoji\7.png")) {
    image.src = "emoji\8.png";
  } else {
    image.src = "emoji\1.png";
  }      
}
<!doctype html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="zh">

< <img id="boy" onclick="run()" src="https://stackoverflow.com/questions/37643551/emoji\walk.png">
  <br>running boy
  <br>
  <img id="moon" onclick="m()" src="emoji\1.png">
  <br>moon

  <script>
  </script>

solved javascript not working (if else ) [closed]