G
G
gomer17262017-11-11 15:51:30
Web development
gomer1726, 2017-11-11 15:51:30

How to sort text in JS?

I want to sort the list:

<div id="content">
     <p id="1">English</p>
     <p id="2">Русский</p>
     <p id="3">English</p>
</div>

It is necessary that the paragraph "Russian" was in the first place.
How to do this in JS or JQUERY?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Daniil Maslov, 2019-08-19
@s0xzwasd

Progressive Web Application

0
0xD34F, 2017-11-11
@gomer1726

And what about sorting?
Do this:

document.getElementById('content').insertBefore(
  document.getElementById('2'),
  document.getElementById('1')
);

Or like this:
$('#2').insertBefore('#1');

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question