String containing double quotation(") gets unexpected identified error

Asked 1 years ago, Updated 1 years ago, 29 views

I would like to display the three sentences in the here part of Div without randomly moving the page, but I get an unexpected identified error in the array.Why?

<div id="here"></div>
​
      <script type="text/javascript">
        var list = [
      "<divid="quiz1" data-role="page">divid="imgContainer">>imgid="imageFullScreen" src="img/ss1.png">>/div>p>p>problem magnification above>>Can't you see any letters?If you know what's written, write your answers below!</p><form name="Sample1_form">>>Answer:<input type="text" name="answer" placeholder="Enter here"><<input type="button"value="Answer!" id="btn/"on>pick=">"
      <divid="quiz2" data-role="page">divid="button" class="btn">???</div>Problem:<br>Let's press and hold the circle above with your finger.When a character appears, please enter it.<br><p>Answer:<input type="text" name="answer" placeholder="Enter here"><input type="button" value="Answer!" id="btn" onclick="showPage()">/pt;>>div;
      "<div id="quiz3" class="page" data-role="page"><div id="MainView_Area"><ul><li><img src="./img/ss2.png" alt="画像1" /></li><li><img src="./img/ss3.png" alt="画像2" /></li><li><img src="./img/ss4.png" alt="画像3" /></li></ul></div><div class="setsumon">問題:<br>上の画像を左に向かって動かしてGive it to me. Can't you see any letters?If you know what's written, write your answers below!<br><p>Answer:<input type="text" name="answer" placeholder="Enter here">>input type="Button" value="Answer!" id="btn" onclick="showPage()">>>/ptiv;>>>>>div
      ];
​
      var num = Math.floor(Math.random()*list.length);
      document.getElementById('here').innerHTML=list[num];
      </script>

javascript

2022-09-30 20:18

2 Answers


as an element of an array "<divid="quiz1" data-role="page">divid="imgContainer">imgid="imageFullScreen" src="img/ss1.png"></div>>>> magnify the image on the issue.Can't you see any letters?If you know what's written, write your answers below!</p><form name="Sample1_form">>>Answer:<input type="text" name="answer" placeholder="Enter here"><<input type="button"value="Answer!" id="btn/"on>pick=">" It looks like
You cannot use " in strings enclosed by " and ".
(You can escape with \ but it's easier to enclose it with ' in this case.)
Please change it to surround it with '.

Example:
'<divid='quiz1' data-role='page'>divid='imgContainer'>imgid='imageFullScreen'src='img/ss1.png'>>> magnify the image on the issue.Can't you see any letters?If you know what's written, write your answers below!</p><form name="Sample1_form">>>Answer:<input type="text" name="answer" placeholder="Enter here"><<input type="button"value="Answer!" id="btn/"on>pick=">"


2022-09-30 20:18

Try converting a double-quotation of the three elements into a single-quotation.(Example: Below)

<div id="here"></div>
  <script type="text/javascript">
    var list = [
  "<divid='quiz1'data-role='page'><divid='imgContainer'>>imgid='imageFullScreen'src='img/ss1.png'>>/div>p>p>p>problem magnification above>>Can't you see any letters?If you know what's written, write your answers below!</p><form name='Sample1_form'>>>Answer:<input type='text'name='answer'placeholder='Enter here'>>input type='button'value='Answer!'id='btn/'on'show>'>pickage'>
  "<divid='quiz2'data-role='page'><divid='button'class='btn'>?</div>Problem:<br>Let's press and hold the circle above with your finger.When a character appears, please enter it.<br><p>Answer:<inputtype='text'name='answer'placeholder='Enter here'>>inputtype='button'value='Answer!'id='btn'onclick='showPage()'>/pt;>>div;
  "<div id='quiz3' class='page' data-role='page'><div id='MainView_Area'><ul><li><img src='./img/ss2.png' alt='画像1' /></li><li><img src='./img/ss3.png' alt='画像2' /></li><li><img src='./img/ss4.png' alt='画像3' /></li></ul></div><div class='setsumon'>問題:<br>上の画像を左に向かって動かしてGive it to me. Can't you see any letters?If you know what's written, write your answers below!<br><p>Answer:<inputtype='text'name='answer'placeholder='Enter here'>>inputtype='button'value='Answer!'id='btn'onclick='showPage()'>/pt;>>div>>>>
  ];
  var num = Math.floor(Math.random()*list.length);
  document.getElementById('here').innerHTML=list[num];
  </script>

According to the questioner's way of writing, quiz1 and so on are treated like variables, resulting in syntax errors.


2022-09-30 20:18

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.