私は HTML5 と Javascript の初心者で、セクションの位置をイベントで入れ替える基本的な関数を作成したいと考えています。
関数 1 は動作しており、セクション「con」を先頭にスワップしていますが、関数 2 は動作しません。
誰か助けてください。
function swap1()
{
document.getElementById("top").style.position = "absolute";
document.getElementById("con").style.top = "50px";
}
function swap2()
{
document.getElementById("con").style.position = "fixed";
document.getElementById("top").style.bottom = "300px";
}
<section id="top" onmousedown="swap1()">
<video width="500" height="500" controls>
<source src="http://techslides.com/demos/sample-videos/small.mp4" type=video/mp4>
</video>
</section>
<section id="con" onmouseover="swap2()">
<hr>
<p>Text.</p>
</section>