Created
May 23, 2012 12:21
-
-
Save Jacqopb/2774972 to your computer and use it in GitHub Desktop.
KlickIt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>Jacobs jquery demo</title> | |
<style> | |
body { | |
background : #346; | |
font-family: Georgia; | |
} | |
#controller { | |
background : #EEE; | |
padding: 20px; | |
cursor: pointer; | |
} | |
.slave{ | |
background : #DDD; | |
cursor: pointer; | |
display : none; | |
padding: 10px; | |
margin-top: 5px | |
} | |
</style> | |
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> | |
<script type="text/javascript"> | |
$(document).ready(function() { | |
var slaves = 0; | |
$('#controller').click(function() { | |
addSlaveDIV('#qContainer') | |
}); | |
$('#controller').dblclick(function() { | |
$('#qContainer').slideUp(1000, function() { | |
$('#qContainer').html(''); | |
$('#qContainer').show(); | |
}); | |
}); | |
function addSlaveDIV(parent) { | |
var currentSlave = ++slaves; | |
$(parent).append('<div class="slave" id="slave' + currentSlave + '"> Dubbelklicka för att döda slav ' + currentSlave + '</div>'); | |
$('#slave' + currentSlave).slideDown(200); | |
$('#slave' + currentSlave).dblclick(function(){ | |
$(this).slideUp(100, function(){ $(this).remove(); }); | |
}); | |
} | |
}); | |
</script> | |
</head> | |
<body> | |
<div id="controller"> Starta klickeriet (dubbelklicka för att rensa allt)</div> | |
<div id="qContainer"></div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment