Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/417.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript ID,您将获得副本。感谢您指出重复字母的问题。在你指出之后,我一直在努力解决这个问题,但我想不出来。我想我会在一个单独的帖子里寻求帮助。谢谢啊哈!我确实尝试过这个,但当我使用可见性使所有字母都显示在块中时,我并没有将display设置为inline-par_Javascript_Html_Css - Fatal编程技术网

Javascript ID,您将获得副本。感谢您指出重复字母的问题。在你指出之后,我一直在努力解决这个问题,但我想不出来。我想我会在一个单独的帖子里寻求帮助。谢谢啊哈!我确实尝试过这个,但当我使用可见性使所有字母都显示在块中时,我并没有将display设置为inline-par

Javascript ID,您将获得副本。感谢您指出重复字母的问题。在你指出之后,我一直在努力解决这个问题,但我想不出来。我想我会在一个单独的帖子里寻求帮助。谢谢啊哈!我确实尝试过这个,但当我使用可见性使所有字母都显示在块中时,我并没有将display设置为inline-par,javascript,html,css,Javascript,Html,Css,ID,您将获得副本。感谢您指出重复字母的问题。在你指出之后,我一直在努力解决这个问题,但我想不出来。我想我会在一个单独的帖子里寻求帮助。谢谢啊哈!我确实尝试过这个,但当我使用可见性使所有字母都显示在块中时,我并没有将display设置为inline-parade(像您一样)。谢谢,这个有用!啊哈!我确实尝试过这个,但当我使用可见性使所有字母都显示在块中时,我并没有将display设置为inline-parade(像您一样)。谢谢,这个有用!谢谢听起来这是一个很好的方法,我也要试试这个!谢谢听起来


ID,您将获得副本。感谢您指出重复字母的问题。在你指出之后,我一直在努力解决这个问题,但我想不出来。我想我会在一个单独的帖子里寻求帮助。谢谢啊哈!我确实尝试过这个,但当我使用可见性使所有字母都显示在块中时,我并没有将display设置为inline-parade(像您一样)。谢谢,这个有用!啊哈!我确实尝试过这个,但当我使用可见性使所有字母都显示在块中时,我并没有将display设置为inline-parade(像您一样)。谢谢,这个有用!谢谢听起来这是一个很好的方法,我也要试试这个!谢谢听起来这是一个很好的方法,我也要试试这个!
    <body>
      <div id="container">
      <div id="hangman">
      <div id="stand"></div>
      <div id="face"></div>
      <div id="body"></div>
      <div id="left-arm"></div>
      <div id="right-arm"></div>
      <div id="left-leg"></div>
      <div id="right-leg"></div>

      </div>

    <div id="alphabet">

    </div>
    <div id="gameOver"><p>Game Over!<br>PS: I am not "actually" being hanged</p>
    </div>
<div id="beingGuessedWord"></div>
      #container {
         height:450px;
         width:600px;
         border:2px solid grey;
         border-radius:5px;
         background-color:hsla(115, 100%, 16%, 1);
         position:relative;  

         }

        #stand {

        background-image:url('http://i59.tinypic.com/sbll48.png');
        height:220px;
        width:200px;

       }

        #face {
        background-image:url('http://i59.tinypic.com/6dx0ee.png');
        height:60px;
        width:60px;
        position:relative;
        top:-175px;
        left:155px;
        visibility:hidden;  



        }

        #body {
        background-image:url('http://i61.tinypic.com/27ywcg.png');
        background-repeat: no-repeat;
        position:relative;
      height:50px;
      top:-175px;
      left:155px;
      visibility:hidden;  

      }

      #left-arm {
      background-image:url('http://i58.tinypic.com/2evvvac.png');
      background-repeat: no-repeat;
      position:relative;
      height:70px;
      width:40px;
      top:-240px;
      left:150px;
      visibility:hidden;  


      }

     #right-arm{
     background-image:url('http://i58.tinypic.com/vfuhyp.png');
     background-repeat: no-repeat;
     position:relative;
     height:70px;
     width:40px;
     top:-300px;
     left:190px;
     visibility:hidden;  

     }

     #left-leg{
     background-image:url('http://i57.tinypic.com/t4u5na.png');
     background-repeat: no-repeat;
     position:relative;
     height:60px;
     width:60px;
     top:-335px;
     left:135px;
     visibility:hidden;  

     }

    #right-leg{
    background-image:url('http://i61.tinypic.com/2dqplzb.png');
    background-repeat: no-repeat;
    position:relative;
    height:50px;
    width:60px;
    top:-385px;
    left:180px;
    visibility:hidden; 

    }

    #alphabet {
    height:100px;
    width:250px;
    position:relative;
    top:-450px;
    left:300px;
    text-align:center;

    }

    #alphabet a {
    font-size:20px;
    text-decoration:none;
    margin:5px;
    font-family: 'Crafty Girls', cursive;
    font-weight:bold;
    color:grey;

    }

    #beingGuessedWord {
    height:70px;
    width:300px;
    position:relative;
    top:-500px;
    left:80px;
    padding-top:50px;

    }

   .letterp {
    border:2px solid black;
    font-family:"Crafty Girls", cursive;
    font-size:20px;
    margin:10px;
    font-weight:bold;
    padding:5px;
    border-radius:5px;


    }

   #dash {
   padding:5px;
   margin:5px;
   font-weight:bold;
   font-family:serif;

  }

  #gameOver {
  border:3px solid grey;

  font-family:'Crafty Girls', cursive;
  font-size:15px;
  font-weight:bold;
  position:relative;
  top:-670px;
  left:300px;
  height:70px;
  width:280px;   
  border-radius:5px;
  text-align:center;   
  visibility:hidden;      

 }
var totalIncorrectClicks = 0;//Global variable

var clickLetter = function() {


  var clickedLetter = document.getElementById(this.id);  
  var word = clickedLetter.getAttribute("data-word");


    var compareSuccess = false;
    for (var i = 0; i < word.length; i++) {

      if (word[i] == clickedLetter.innerHTML) 
      {

          var pId = "id" + word[i];

          var pNode = document.getElementById(pId);
          pNode.style.display = "inline";
          compareSuccess = true;

      }

    }

    if (compareSuccess == false)
    {
        totalIncorrectClicks++;
    }

    if (compareSuccess == false && totalIncorrectClicks <=7)
    {
        if (totalIncorrectClicks == 1)
        {
        var face = document.getElementById('face');
        face.style.visibility = "visible";
        }

         if (totalIncorrectClicks == 2)
        {
        var body = document.getElementById('body');
        body.style.visibility = "visible";
        }

         if (totalIncorrectClicks == 3)
        {
        var leftArm = document.getElementById('left-arm');
        leftArm.style.visibility = "visible";
        }

         if (totalIncorrectClicks == 4)
        {
        var rightArm = document.getElementById('right-arm');
        rightArm.style.visibility = "visible";
        }

         if (totalIncorrectClicks == 5)
        {
        var leftLeg = document.getElementById('left-leg');
        leftLeg.style.visibility = "visible";
        }

         if (totalIncorrectClicks == 6)
        {
        var rightLeg = document.getElementById('right-leg');
        rightLeg.style.visibility = "visible";
        }

        if (totalIncorrectClicks == 7)
        {
            var gameOver = document.getElementById('gameOver');
            gameOver.style.visibility = "visible";
        }
    }


}

var createAlphabets = function () {
  var alphabets = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'];

for (var i = 0; i < alphabets.length; i++)
  {
    var anchorNode = document.createElement('a');
    var idanch = "id" + (i+1);


    anchorNode.setAttribute('id', idanch);


    anchorNode.innerHTML = alphabets[i];

    anchorNode.setAttribute('href', "#");


    var alphaDiv = document.getElementById('alphabet')

    alphaDiv.appendChild(anchorNode);

    if (i == 11 || i == 22)
      {
        alphaDiv.innerHTML = alphaDiv.innerHTML + "<br>"

      }


  }
}

var selectWord = function() {

  var wordArray = ["air", "clouds", "sun"];
  var randomWord = wordArray[Math.floor(Math.random() * wordArray.length)];
  var splitRandomWord = randomWord.split('');

  return splitRandomWord;

}


var displayWord  = function(word) {


  for (var i = 0; i < word.length; i++) {


    var dispWordDiv = document.getElementById('beingGuessedWord');


    var pNode = document.createElement('p');

    pNode.innerHTML = word[i];
    var id = "id" + word[i];
    pNode.setAttribute('id', id);
    pNode.setAttribute('class', "letterp");  
      pNode.style.display = "none";

    dispWordDiv.appendChild(pNode);

  }

  var dispWordDiv  = document.getElementById('beingGuessedWord');
  dispWordDiv.innerHTML = dispWordDiv.innerHTML + "<br>"; 

  for (var i = 0; i < word.length; i++) {
      var dispWordDiv  = document.getElementById('beingGuessedWord');
      var empty = document.createElement('p');
      empty.setAttribute('id', 'dash');
      empty.innerHTML = "___";
      empty.style.display = "inline";



    dispWordDiv.appendChild(empty);
  }
  }

  var word = selectWord();
  createAlphabets();
  displayWord(word);
  for (var i = 0; i < 27 ; i++) {
  var id = "id" + ( i + 1 );
  var anchor  = document.getElementById(id);
  anchor.setAttribute('data-word', word);    
  anchor.onclick = clickLetter;
}
<table>
 <tr>
  <td> 1st hidden char </td>
  <td> 2nd hidden char </td>
  ...
  <td> Nth hidden char</td>
 </tr>
 <tr>
  <td> 1st underline _ </td>
  <td> 2nd underline _ </td>
  ...
  <td> Nth underline _ </td>
 </tr>
</table>
if (word[i] == clickedLetter.innerHTML) 
  {

      var pId = "id" + word[i];

      var pNode = document.getElementById(pId);
      pNode.style.visibility = "visible";
      compareSuccess = true;

  }