That depends upon your current code and how you plan to activate it. The example I offered is set so that when the <li> is clicked, it will re-arrange things so that ANYWHERE within the li, if there is a URL, it will be put to the end. Unless it’s already at the end… or if it’s at the beginning, it may not work… I’m not sure… didn’t test for that.
You can set any event you like (click, load, mouseover, a change in another element, etc.) What is the context of your site/app?
The selector of the code I provided is jQuery shorthand for all <li> elements, I think. If you have more than one li and the click is only working on the first, I can’t understand why. Please provide your relevant code… maybe I can see something.
UPDATE: Ah. Gave it some more thought… I didn’t use .each(). Perhaps that will only affect the first one. Do you know enough about jQuery to modify that to work within .each()?
Taking a closer look at it, it’s not as robust as I thought it might be. Won’t work if the URL is first, and even if it’s in the second slot, it won’t work because the order of the backreferences is set, not dynamic.
Still… it worked better this way than when I tried splitting it into an array and going from there.
… AAAAAAAAAAAAND… I haven’t tested it, however, I believe that if you keep the break; in, it will only push one URL to the end - but if you remove it, I think it will put all URLs (if more than one) at the end.
UPDATE: NOPE! It won’t. But only because after the first slice/push, the indeces have changed by one.