Note that there are some explanatory texts on larger screens.

plurals
  1. POHow would I make a div tag move up or down with a click of a link (with Javascript)?
    primarykey
    data
    text
    <p>I have 4 'headers' (they are a div tag with a link that opens up the hidden area of each header... this is to neatly organize everything for a mobile device while still having alot of content) Point is i'm getting at here... these headers are all the same sized collapsed, but NOT when they are expanded.</p> <p>What I need to be able to do is to click a link and the header moves up, click another link and it would move down. So i have 1,2,3,4... I click 'up' on 2, and now 2 is where 1 was, and 1 is where two was. </p> <p>Currently, I have header 1 at the top, then I have content that will be edited quite frequently, then I have the other 3 headers. I just want to add an 'up' link and a 'down' link that'll swap the entire div with the one above/below it </p> <p>EDIT: Right now, I have </p> <pre><code>function toggle() { var ele = document.getElementById("toggleText"); if(ele.style.display == "block") { ele.style.display = "none"; } else { ele.style.display = "block"; } } </code></pre> <p>for each of my headers (so 4 seperate javascript functions)</p> <p>and in short this is what my page is like:</p> <p>--Nav Links--</p> <p><br /> ~~Header 1~~ <br /> content <br /> ~~Header 2~~ <br /> ~~Header 3~~ <br /> ~~Header 4~~</p> <p>Theres a only a break tag seperating them while they are collapsed. I want to add a link to each header so when I click it, it will swap positions with the one above/below it.</p> <p>Does this help explain it any better?</p> <p>And i'd prefer to stick to Javascript if at all possible</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload