JavaScript Any ideas on how to number each side of a ul with items inside of it?

I'd just use CSS for this. I'm on the bus that's about to arrive, but here's a quick JSFiddle.

The key to this solution is CSS counters.

body {
  counter-reset: li-counter;
}
li {
  counter-increment: li-counter;
}
li:before,
li:after {
  position: absolute;
  top: 45%;
  display: block;
  content: counter(li-counter);
}

I'll update more with browser support, alternative solutions, etc., once I'm at home!

Edit: Gaby jumped in and wrote up basically exactly where I was going with this, so I won't elaborate on this any further. With that said, it seems like we might need more information to help you out. I wrote a bit of a long comment on the question that tries to clarify further what you might be going for.

Answer:1

On a tree layout using d3.js (example), I'd like to collapse nodes that are not in the branch that has been clicked on. For example, in the above demo, try the following: click on "Parent 1" (Child ...

On a tree layout using d3.js (example), I'd like to collapse nodes that are not in the branch that has been clicked on. For example, in the above demo, try the following: click on "Parent 1" (Child ...

Magento Javascript Question Does anyone know how I can call the session singleton in Javascript? I have a validation to a form like this which, everytime it validates the checkbox element, I want to ...

Magento Javascript Question Does anyone know how I can call the session singleton in Javascript? I have a validation to a form like this which, everytime it validates the checkbox element, I want to ...

  1. magento save data in custom table
  2. magento save data in cache
  3. magento save data in session
  4. magento save data
  5. magento save data to quote
  6. magento 2 save data in custom table
  7. magento 2 save data in model
  8. magento 2 save data into custom model
  9. magento 2 save data in session
  10. magento 1.9 save data in custom table
  11. magento 2 save data in database
  12. magento 2 save data in controller
  13. magento 2 save data to cache
  14. magento 2 save data
  15. magento save form data in database
  16. magento 2 save data in checkout session
  17. magento 2 save data using model
  18. magento model save data
  19. magento 1 save data
  20. magento save collection data

I want to design a helper function which would try to execute passed as parameter deep property path and to return value extracted by it. For example consider following code var foo = { bar: ...

I want to design a helper function which would try to execute passed as parameter deep property path and to return value extracted by it. For example consider following code var foo = { bar: ...

  1. javascript create universal function

How to dismiss Bootstrap popover by clicking outside the popover. Currently it has toggle for open link. HTML <div class="widget-rating"> <span class="rateit rating-average">&...

How to dismiss Bootstrap popover by clicking outside the popover. Currently it has toggle for open link. HTML <div class="widget-rating"> <span class="rateit rating-average">&...

  1. dismiss bootstrap popover programmatically
  2. dismiss bootstrap popover
  3. dismiss bootstrap popover on click
  4. bootstrap dismiss popover click outside
  5. bootstrap popover dismiss button
  6. bootstrap popover dismiss on next click
  7. bootstrap popover dismiss not working
  8. popover dismiss bootstrap 4
  9. bootstrap popover dismiss event
  10. popover dismiss bootstrap 3
  11. bootstrap popover dismiss ios