Reputation:
It's there any method that I can use for moving the content between DIVs without the jQuery or JavaScript ?
Example:
<div id="1">firstDiv</div>
<div id="2">secondDiv</div>
Result:
in DIV with id = 1 will be the content -> secondDiv
in DIV with id = 2 will be the content -> firstDiv
Thank you!
Upvotes: 2
Views: 345
Reputation: 32192
Now used to flex
in CSS like this:
#divflex { display: flex; flex-direction: column; }
#two { order: 1; }
#one { order: 2; }
<div id="divflex">
<div id="one">firstDiv</div>
<div id="two">secondDiv</div>
</div>
More about flex order.
Upvotes: 1
Reputation: 123397
Use Flexbox
with direction column-reverse
body {
display: flex;
flex-direction: column-reverse;
}
Upvotes: 1
Reputation: 524
There is no way to do it without javascript or jquery, if use javascript, read the following code.
var divOneContent = document.getElementById('one').innerHTML;
var divTwoContent = document.getElementById('two').innerHTML;
// move
document.getElementById('one').innerHTML = divTwoContent;
document.getElementById('two').innerHTML = divOneContent;
<div id="one">
one
</div>
<div id="two">
two
</div>
Upvotes: 1
Reputation: 1033
no way without javascript - you cant change the dom otherway
let div1 = document.getElemenentById("1");
let div2 = document.getElemenentById("2");
let div1Content = div1.innerHTML;
let div2Content = div2.innerHTML;
div1.innerHTML = div2Content;
div2.innerHTML = div1Content;
Upvotes: 0