Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Here is a similar question:</p> <p><a href="https://stackoverflow.com/questions/5881033/how-to-generate-ul-li-list-from-string-array-using-jquery">How to generate UL Li list from string array using jquery?</a></p> <p>Here is your corrected code:</p> <pre><code> $(function () { var wgScript = "http://benfutbol10.wikia.com/wiki/MediaWiki:Emoticons?action=raw&amp;ctype=text/css"; $.ajax({ 'dataType': 'text', 'url': wgScript, 'success': function (data) { var $chat = $('#Chat_15028'); var $lista = $('&lt;ul&gt;').attr('id', 'listaEmoticones'); $chat.prepend($lista); var lines = data.split("\n"); var src, txt, $opt, $img, $span; for (var i = 0; i &lt; lines.length; i++) { if (lines[i].indexOf('* ') == 0) { src = lines[i].substring(2); } else { $img = $('&lt;img&gt;').attr('src', src); $span = $('&lt;span&gt;').text(lines[i].substring(3)); $opt = $('&lt;li&gt;').append($img).append($span); $lista.append($opt); } } } }); }) </code></pre> <p>Here is a fiddle I built to demonstrate it: <a href="http://jsfiddle.net/Es2n2/3/" rel="nofollow noreferrer">http://jsfiddle.net/Es2n2/3/</a></p> <pre><code> var $chat = $('#Chat_15028'); $lista = $('&lt;ul&gt;').attr('id', 'listaEmoticonesB'); $chat.prepend($lista); var data = "* http://images2.wikia.nocookie.net/__cb20110904035827/central/images/7/79/Emoticon_angry.png\n** (angry)\n** &gt;:O\n** &gt;:-O\n* http://images1.wikia.nocookie.net/__cb20110904035827/central/images/a/a3/Emoticon_argh.png\n** (argh)"; var lines = data.split("\n"); var src, txt, $opt, $img, $span; for (var i = 0; i &lt; lines.length; i++) { if (lines[i].indexOf('* ') == 0) { src = lines[i].substring(2); } else { $img = $('&lt;img&gt;').attr('src', src); $span = $('&lt;span&gt;').text(lines[i].substring(3)); $opt = $('&lt;li&gt;').append($img).append($span); $lista.append($opt); } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload