Skip to content

Instantly share code, notes, and snippets.

@najamkhn
Created December 18, 2013 10:07
Show Gist options
  • Save najamkhn/8019979 to your computer and use it in GitHub Desktop.
Save najamkhn/8019979 to your computer and use it in GitHub Desktop.
.divfactory {
background: red;
width: 20px;
height: 20px;
position: relative;
margin: 10px;
-moz-box-shadow: 2px 2px 5px #888;
-webkit-box-shadow: 2px 2px 5px #888;
box-shadow: 2px 2px 5px #888;
}
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script><html>
<body>
<div class="content">
</div>
<a href="#" class="add-box">Add a Box</a>
</body>
</html>
jQuery(document).ready(function(){
var counter = 0;
$('.add-box').click(function(){
var divFactory = $('<div class="divfactory" />');
console.log(divFactory);
divFactory.attr('id', 'box-' + counter++);
$(document.body).append(divFactory);
return false;
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment