Jump to content
Sign in to follow this  
sanjog

jquery, adding content everytime when the button is clicked.

Recommended Posts

Hello, I created a button and have a checkbox form. I want to add that form one by one everytime when the button is clicked,

I have tried by clone() method, it worked but the checkbox didn't work, i mean i couldn't check in the box or it checks in all of the form. I need help.

 

Here is peice of my code...

<html>

<button id="check-type">Multiple choice</button>

 

<div class="multiple-choice">
<input id="check1" type="checkbox" name="check" value="check1">
<label for="check1">ques1</label><br> <br>
<input id="check2" type="checkbox" name="check" value="check2">
<label for="check2">ques2</label><br><br>
</div>
</html>
<script>
$('#check-type').click(function(){
$('.multiple-choice').show(); //shows only once, but i want to add this form everytime when the button is clicked.
});

</script>

Share this post


Link to post
Share on other sites

If you're going to clone nodes then keep in mind that 2 elements on the page cannot have the same ID. Either get rid of the IDs or change them when you clone the node, before adding the new nodes.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...