Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <style>
- #dv{
- border:1px solid red;
- background-color:#344;
- height:80px;
- position:absolute;
- }
- #dv2{
- border:1px solid black;
- background-color:#f00;
- height:80px;
- position:absolute;
- }
- </style>
- <body>
- <div id = "dv"></div>
- <div id = "dv2"></div>
- <script>
- var valor = 0;
- var valor2 = 180;
- var dv= document.getElementById("dv");
- var div2 = document.getElementById("dv2");
- var largura = dv.style.width = 80;
- var lateral = div2.style.left = 180;
- var largura2 = div2.style.width = 80;
- var lateral2 = div2.style.top = 300;
- function moverDiv(){
- valor += 5;
- dv.style.left = valor+"px";
- if(valor+largura > lateral){
- div2.style.backgroundColor = "blue";
- }
- }
- dv.addEventListener("touchmove",moverDiv);
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement