Toggle navigation
Bootsnipp
Bootstrap
For
CSS Frameworks
Bootstrap
Foundation
Semantic UI
Materialize
Pure
Bulma
References
CSS Reference
Tools
Community
Page Builder
Form Builder
Button Builder
Icon Search
Dan's Tools
Diff / Merge
Color Picker
Keyword Tool
Web Fonts
.htaccess Generator
Favicon Generator
Site Speed Test
Snippets
Featured
Tags
By Bootstrap Version
4.1.1
4.0.0
3.3.0
3.2.0
3.1.0
3.0.3
3.0.1
3.0.0
2.3.2
Register
Login
"Append div"
Bootstrap 3.3.0 Snippet by
Mithu
3.3.0
jQuery
Preview
HTML
CSS
JS
View Full Screen
Fork
Fork this
7.7K
 
3 Fav
Post to Facebook
Tweet this
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css"> <script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/js/bootstrap.min.js"></script> <script src="//code.jquery.com/jquery-1.11.1.min.js"></script> <!------ Include the above in your HEAD tag ----------> <div class="container"> <div class="row"> <div class="form-group col-md-12"> <label for="storeName">Option Value *</label> <div class="clearfix"></div> <label class="margin-right"><input type="radio" name="colorRadio" value="red"> Single</label> <label><input type="radio" name="colorRadio" value="green"> Multiple </label> <div class="red box" > <input id="multiValue" class="form-control" type="text" placeholder="Add Value" value="" name="multiValue[]" size="20" style=" border: 1px solid rgba(0,0,0,0.3); float: left; margin-bottom: 10px;"> </div> <div class="green box" id="hereToadd"> <ul> <li> <input id="multiValue" class="form-control" type="text" placeholder="Add Value" value="" name="multiValue[]" size="20" style=" border: 1px solid rgba(0,0,0,0.3); float: left; margin-bottom: 10px;"> </li> <li> <div class="btn-group"> <button type="button" class="btn btn-primary addValue">+</button> </div> </li> </ul> </div> </div> </div> </div>
.box{ padding: 0px; display: none; margin-top: 10px; clear: both; } .red{display: block} .green{} .green ul li{ float: left; } .green ul li:nth-child(1){ width: 93%; padding-right: 5px; } .green ul li:nth-child(2){ width: 7%; } .green ul li .btn { border: 1px solid transparent; border-radius: 0 !important; cursor: pointer; display: inline-block; font-size: 20px; font-weight: 400; line-height: 26px; margin-left: 1px !important; padding: 5px 12px; }
$(document).ready(function(){ $('input[type="radio"]').click(function(){ if($(this).attr("value")=="red"){ $(".box").not(".red").hide(); $(".red").show(); } if($(this).attr("value")=="green"){ $(".box").not(".green").hide(); $(".green").show(); } if($(this).attr("value")=="blue"){ $(".box").not(".blue").hide(); $(".blue").show(); } }); }); $(document).on('click','.addValue',function(e){ e.preventDefault(); $('<ul><li><input id="multiValue" class="form-control" type="text" placeholder="Add Value" value="" name="multiValue[]" size="20" style=" border: 1px solid rgba(0,0,0,0.3); float: left; margin-bottom: 10px;"></li><li><div class="btn-group"><button type="button" class="btn btn-primary" id="deleteParent">-</button><button type="button" class="btn btn-primary addValue">+</button></div></li></ul>').appendTo('#hereToadd'); }); $(document).on('click','#deleteParent',function(e){ e.preventDefault(); $(this).parent().parent().parent().remove(); });
Related:
See More
Template
Now UI Kit PRO Angular
Questions / Comments:
Post
Posting Guidelines
Formatting
- Now
×
Close
Donate
BTC: 12JxYMYi6Vt3mx3hcmP3B2oyFiCSF3FhYT
ETH: 0xCD715b2E3549c54A40e6ecAaFeB82138148a6c76