How to click on the element and move to the first in javascript?
Question
There is a list as below.
1 | <ul> |
If I want to move A or B or C to the first place after clicking on it, what should I do?
Answer
By using JQuery method prepend
to make it happen.
Solution:
1 | <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> |
1 | $('ul li').click(function(event) { |
Reference
This is the end of post