I'm not sure if this would be the best option.. But I want the option that when the user clicks a button, it will add another div or li.
I am going to allow users to upload documents, but multiple ones. I'd like to for the user to be able to click a button, and a new <div>
or <li>
is generated with predefined code. Is this possible?
Here's a fiddle..
http://jsfiddle.net/AHvwP/1/
Try this:
$('.button').click(function() {
$('#myContainer').append('<div>the new guy</div>');
});
Your example updated on jsFiddle
$("input[type=submit]").click(function(){
$("<li />").html("item").appendTo("ul");
})
You can create elements using $("<tag />")
and set attributes, add classes and so on. Then append where you want.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With