Skip to content

Instantly share code, notes, and snippets.

@mcorkum
Created May 13, 2016 00:57
Show Gist options
  • Save mcorkum/618abb1c5981e3992e3509df9c858029 to your computer and use it in GitHub Desktop.
Save mcorkum/618abb1c5981e3992e3509df9c858029 to your computer and use it in GitHub Desktop.
Hover
$(document).ready(function(){
function getRandomPosition(element) {
var x = 400;
var y = 400;
var randomX = Math.floor(Math.random()*x+50);
var randomY = Math.floor(Math.random()*y-200);
return [randomX,randomY];
}
window.onload = function() {
var liDecorate = document.getElementsByClassName('container');
for (i=0; i<liDecorate.length; i++) {
liDecorate[i].setAttribute("style", "position:absolute;");
var xy = getRandomPosition(liDecorate[i]);
liDecorate[i].style.top = xy[0] + 'px';
liDecorate[i].style.right = xy[1] + 'px';
}
}
$(".formBox").on("submit", function () {
var liDecorate = document.getElementsByClassName('container');
for (i=0; i<liDecorate.length; i++) {
liDecorate[i].setAttribute("style", "position:absolute;");
var xy = getRandomPosition(liDecorate[i]);
liDecorate[i].style.top = xy[0] + 'px';
liDecorate[i].style.right = xy[1] + 'px';
}
});
$( ".bulb" ).hover(
function() {
$( this ).parent('.container').find('.feedback').css("opacity", 1);
$( this ).parent('.container').css("z-index", 4);
}, function() {
$( this ).parent('.container').find('.feedback').css("opacity", 0);
$( this ).parent('.container').css("z-index", 1);
}
);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment