Skip to content

Instantly share code, notes, and snippets.

@Jacqopb
Created May 23, 2012 12:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Jacqopb/2774972 to your computer and use it in GitHub Desktop.
Save Jacqopb/2774972 to your computer and use it in GitHub Desktop.
KlickIt
<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