How to insert large blocks of information?

Question for append. Why does such a script works
the <script>
$( ".wo3" ).append( "<p>Test</p>" );
</script>
and there is no such
the <script>
$( ".wo3" ).append( "<span class="mb w ch">
<span class="w">我</span>
<span class="p1"> wǒ </span>
<span class="p2"> wɔ↝ </span>
<span class="p3"> wɔ3 </span> 
<img class="an" src="/Strokeorder/grammar_hsk1/3-1-0-9/wo3.gif">
<a class="sound" data-sound="grammar_hsk1/3-1-0-9/ch/wo3.mp3"></a>
</span>" );
</script>
June 10th 19 at 15:45
2 answers
June 10th 19 at 15:47
Solution
Problem is in quotation marks and hyphens
$( ".wo3" ).append([
 '<span class="mb ch w">',
 '<span class="w">我</span>',
 '<span class="p1"> wǒ </span>',
 '<span class="p2"> wɔ↝ </span>',
 '<span class="p3"> wɔ3 </span>',
 '<img class="an" src="/Strokeorder/grammar_hsk1/3-1-0-9/wo3.gif">',
 '<a class="sound" data-sound="grammar_hsk1/3-1-0-9/ch/wo3.mp3"></a>',
'</span>',
].join(""));

or
$( ".wo3" ).append( '<span class="mb w ch">\
 <span class="w">我</span>\
 <span class="p1"> wǒ </span>\
 <span class="p2"> wɔ↝ </span>\
 <span class="p3"> wɔ3 </span>\
 <img class="an" src="/Strokeorder/grammar_hsk1/3-1-0-9/wo3.gif">\
 <a class="sound" data-sound="grammar_hsk1/3-1-0-9/ch/wo3.mp3"></a>\
</span>' );
Template strings - simone.Smith77 commented on June 10th 19 at 15:50
I personally don't use this kind of "standardization" and it was not even the need of collecting multi-line information, what I wrote above rather from what I have seen others do. But still saved for the link, I learned that ` account for transfers. - Wava_Berni commented on June 10th 19 at 15:53
June 10th 19 at 15:49
Solution
Because you have quotation marks broken.

There are 2 solutions
1. Embedded quotes must be other (outside double inside single quotes and Vice versa). For example: append("<div class="test"></div>")
2. Embedded quotes must be sesquiplane. For example: append("<div class="\"test\""></div>")
the <script>
 $('.wo3').append(`<span class="mb w ch">
<span class="w">我</span>
<span class="p1"> wǒ </span>
<span class="p2"> wɔ↝ </span>
<span class="p3"> wɔ3 </span> 
<img class="an" src="/Strokeorder/grammar_hsk1/3-1-0-9/wo3.gif">
<a class="sound" data-sound="grammar_hsk1/3-1-0-9/ch/wo3.mp3"></a>
</span>`);
</script>


Here worked. OK so? - simone.Smith77 commented on June 10th 19 at 15:52
, back quotes understand that only the most modern browsers. Use the regular single. - Wava_Berni commented on June 10th 19 at 15:55
the problem is that this quote as there is in the transcription )))) - Lucienn commented on June 10th 19 at 15:58
, seascape her. A backslash before the quotation mark will help you. - Rex.Bayer90 commented on June 10th 19 at 16:01

Find more questions by tags JavaScriptjQuery