0

It is possible to create a two column appearance in a list based on a data attribute of an element? My HTML which can't really be modified into two lists (even using JS breaks other functionality on the page) looks like:

<ul>
    <li data-list="general_results">general text1</li>
    <li data-list="general_results">general text2</li>
    <li data-list="general_results">general text3</li>
    <li data-list="category_results">category text1</li>
    <li data-list="category_results">category text2</li>
    <li data-list="category_results">category text3</li>
    <li data-list="category_results">category text4</li>
</ul>

I want the output to appear as:

general text1               category text1
general text2               category text2
general text3               category text3
                            category text4

It is same to assume that the will always have the elements grouped in order.

I'm not sure how to achieve this with the desired output. Floating places elements in a left to right fashion instead of a vertical layout. Any ideas?

jharry
  • 1
  • so it's like your separating it into two categories? – Sam Teng Wong Jul 23 '15 at 06:48
  • Pretty much but only visually. Kinda need it to stay together semantically. – jharry Jul 23 '15 at 06:51
  • how about using jquery?. you can do something like this. `$('ul li[data-list=general_results]').each(function(){ alert($(this).html()); });` – Sam Teng Wong Jul 23 '15 at 06:52
  • I don't see how that splits them visually? If I place these
  • 's into another element or move from where they are, then the other stuff that's already listening to them breaks and I loose that functionality. As it's something built by another person I don't understand how it works which is why I was hoping for a CSS solution
  • – jharry Jul 23 '15 at 06:54
  • you need to get the value first.... put it on an array... and do a foreach.. append them on different element. ex. `div` – Sam Teng Wong Jul 23 '15 at 07:01
  • I did try that but then the other stuff on the page breaks – jharry Jul 23 '15 at 07:05
  • http://stackoverflow.com/questions/17005407/creating-a-two-column-unordered-list I think this will help you – Jara Skuder Jul 23 '15 at 07:13
  • Check out my answer... hope that's what you're looking for.. =) – Sam Teng Wong Jul 23 '15 at 07:16