Grow your CSS skills. Land your dream job.

Last updated on:

Move Clicked List Items To Top Of List

Assuming HTML like this:

<ul>
  <li>one</li>
  <li>two</li>
  <li>three</li>
</ul>

So if "Two" is clicked, move it to the top of the list.

$("li").click(function() {
     
  $(this).parent().prepend($(this));
  
});

Will work for multiple lists...

Leave a Comment

Current day month ye@r *

*May or may not contain any actual "CSS" or "Tricks".