Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If you're getting it from the database, you probably want to do this on the server side, and add those elements in your HTML; not with jQuery.</p> <p>However, why use <code>&lt;span&gt;</code> elements? The keyword in your title and your question I've seen is <em>list</em> - yet there is no use of (my <em>favorite</em> HTML elements!) <code>&lt;ul&gt;</code> or <code>&lt;ol&gt;</code>.</p> <p>What server-side language are you using? I'll assume PHP... when you read the comma separated list out of the DB, turn it into a list, and then use CSS to add commas. You can do that with a <code>background-image</code> of a comma, or with a CSS <a href="http://www.w3schools.com/CSS/css_pseudo_elements.asp" rel="nofollow noreferrer">pseudo-element</a> and the <a href="http://www.w3schools.com/Css/pr_gen_content.asp" rel="nofollow noreferrer"><code>content</code></a> property.</p> <h2>Example</h2> <p>In a PHP server-side script:</p> <pre><code>&lt;?php $readFromTheDB = "foo, bar, mon, key, base, ball"; $list = $keywordsArray = array_map('trim', explode(',', $readFromTheDB)); echo "&lt;ul&gt;"; $oddEven = true; foreach($list as $listitem) { $class = ($oddEven?"odd":"even"); echo "&lt;li class=\"".htmlentities($class)."\"&gt;".htmlentities($listitem)."&lt;/li&gt;"; $oddEven = !$oddEven; } echo "&lt;ul&gt;"; ?&gt; </code></pre> <p>Then in your CSS file:</p> <pre><code>ul li { background:url(path/to/images/comma.png) BOTTOM RIGHT NO-REPEAT; display:inline; } ul li.even { font-weight:bolder; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

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