Skip to content

Instantly share code, notes, and snippets.

@hoseinBL hoseinBL/jsFUN[1].js
Created May 11, 2013

Embed
What would you like to do?
sry dir shod... systemam kharab bood. Internetam ham tamum shode bud...
<!DOCTYPE HTML>
<html>
<head>
<title>Programming Practice</title>
<style type="text/css">
body{
background-color: lightblue;
}
.btns{
width:200px;
height:60px;
background-color: gray;
color: black;
position: absolute;
left:85%;
top:85%;
font-size:20px;
text-align: center;
line-height:60px;
cursor: pointer;
border-radius: 8px;
-moz-transition: all 100ms;
}
</style>
</head>
<body>
<script type="text/javascript">
for(var i=0;i<10;i++){
document.write('<div class="btns">Can You Click Me</div>');
}
</script>
<script type="text/javascript">
var btns = document.getElementsByClassName('btns');
var rnd = function (max){
return Math.round(Math.random()*max);
};
var Move = function (){
this.style.left=rnd(80)+'%';
this.style.top=rnd(80)+'%';
};
var ColorMaker = function(){
var
r=rnd(255),
g=rnd(255),
b=rnd(255);
return "rgb("+r+","+g+","+b+")";
};
for(var i=0;i<btns.length;i++){
btns.item(i).onmouseover = Move;
btns.item(i).style.backgroundColor = ColorMaker();
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.