Skip to content

Instantly share code, notes, and snippets.

@najamkhn
Created December 18, 2013 09:57
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 najamkhn/8019862 to your computer and use it in GitHub Desktop.
Save najamkhn/8019862 to your computer and use it in GitHub Desktop.
.divfactory {
background: red;
width: 20px;
height: 20px;
position: relative;
margin: 10px;
}
<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