JavaScript How to change div order in javascript change array order javascript,change div order javascript,change object

I want to change the div order through JavaScript. i didn't know how to do that

This is the two div which implement in html, but i want div id="navigation" show in html after div class="row subheader".

<div id="navigation">
  <div class="item" style="display:inline;">
    <a target='_blank' href="index.html">Home</a>
  </div>
  <div class="item" style="display:inline;">Blog: Kannu</div>
</div>

<div class="row subheader">
  <div class="container">
    <div id="blogsubheader">My Blog</div>
  </div>
</div>

I want like this from javascript please check follow.

<div class="row subheader">
  <div class="container">
    <div id="blogsubheader">My Blog</div>
  </div>
</div>

<div id="navigation">
  <div class="item" style="display:inline;">
    <a target='_blank' href="index.html">Home</a>
  </div>
  <div class="item" style="display:inline;">Blog: Kannu</div>
</div>

Thanks in advance

Answer:1

Assuming you're using jQuery, then use this :

$('#navigation').insertAfter( ".container" );
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
</head>
<body>
<div id="navigation">
            <div class="item" style="display:inline;">
                        <a target='_blank' href="index.html">Home</a>
           </div>
    <div class="item" style="display:inline;">Blog: Kannu</div>
 </div>


  <div class="row subheader">
  <div class="container">
   <div id="blogsubheader">My Blog</div>
  </div>
 </div>
</body>
</html>
Answer:2

As you want to change the DOM. First you need to clone the first section and store it in a variable. Then remove the first element from the DOM. And append this element after the 2nd element.

To do so using jQuery

var nav = $('#navigation').clone(true);

$('#navigation').remove();
nav.insertAfter('.subheader'); 

In JavaScript

var nav = document.getElementById('navigation');
var subHeader = document.getElementsByClassName('subheader');

subHeader[0].after(nav);

Here is the fiddle link https://jsfiddle.net/moshiuramit/xm85h29g/7/

Answer:3

How about this?

var navigation = document.getElementById('navigation');
var rowSubheader = document.getElementById('row-subheader');

rowSubheader.after(navigation);

You'll have to add an id here though, as I did:

<div class="row subheader" id="row-subheader">

https://jsfiddle.net/zmve7xyc/

Answer:4

I am coding a php/html page, with some javascript functions. I want to perform an INSERT on my MySQL Database if the result of one of my javascript functions is equal to 1. 01) How can I access the ...

I am coding a php/html page, with some javascript functions. I want to perform an INSERT on my MySQL Database if the result of one of my javascript functions is equal to 1. 01) How can I access the ...

I am trying to make a form where a customer can choose parson and automatically show the cost depend on parson number. So for that, I used jQuery form change function and calculate the cost inside of ...

I am trying to make a form where a customer can choose parson and automatically show the cost depend on parson number. So for that, I used jQuery form change function and calculate the cost inside of ...

I am trying to get some suggestions when I write something in HTML form. Hence,I call a JS function when onkeypress and onkeyup events are triggered on that form. In JS function I am using HTTP ...

I am trying to get some suggestions when I write something in HTML form. Hence,I call a JS function when onkeypress and onkeyup events are triggered on that form. In JS function I am using HTTP ...

  1. running javascript from command line
  2. running javascript from python
  3. running javascript from java
  4. running javascript from terminal
  5. running javascript from html
  6. running javascript from visual studio code
  7. running javascript from c#
  8. running javascript from php
  9. running javascript from command line windows
  10. running javascript from address bar
  11. running javascript from console
  12. running javascript from url
  13. running javascript from command line linux
  14. running javascript from browser
  15. running javascript from bash
  16. running javascript from powershell
  17. running javascript from chrome
  18. running javascript from command prompt
  19. running javascript from code behind c#
  20. running javascript from notepad

I believe I'm wording this question correctly.... I have a dataset like this... [ { "Fri Aug 03 2018 00:00:00 GMT-0500": { "bill": "Test 2", "account": "defaultAccount", "...

I believe I'm wording this question correctly.... I have a dataset like this... [ { "Fri Aug 03 2018 00:00:00 GMT-0500": { "bill": "Test 2", "account": "defaultAccount", "...

  1. sort nested array javascript
  2. sort nested array php
  3. sort nested array mongodb
  4. sort nested array
  5. sort nested array python
  6. sort nested array of objects javascript
  7. sort nested array js
  8. sort nested array java
  9. sort nested array mongoose
  10. mongodb sort nested array
  11. sort nested array typescript
  12. sort array multidimensional php
  13. sort array multidimensional javascript
  14. sort array multidimensional java
  15. sort array multidimensional
  16. sort array by nested value
  17. sort multidimensional array php by value
  18. sort multidimensional array php by key
  19. sort multidimensional array python
  20. sort multidimensional array c#