Last active
March 14, 2017 14:51
-
-
Save MWins/5b28047f211a7a440c3e to your computer and use it in GitHub Desktop.
bootstrap-add panel-remove
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <div class="container"> | |
| <div class="col-md-6"> | |
| <div class="panel panel-default" id="one"> | |
| <div class="panel-heading">Title | |
| <button type="button" id="add" class="pull-right hide">+</button> | |
| </div> | |
| <div class="panel-body">Content here..</div> | |
| </div> | |
| </div> | |
| <div class="panel_row col-md-6"> | |
| <div class="panel panel-default" id="two"> | |
| <div class="panel-heading">Title | |
| <button type="button" id="remove" class="pull-right">-</button> | |
| </div> | |
| <div class="panel-body">Content here..</div> | |
| </div> | |
| </div> | |
| </div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $("#remove").click(function(event) { | |
| $(event.target).closest('.panel').remove(); | |
| $('#one').parent().removeClass('col-md-6'); | |
| $('#one').parent().addClass('col-md-12'); | |
| $('#add').removeClass('hide'); | |
| }); | |
| $('#add').click(function(event) { | |
| $('#one').parent().removeClass('col-md-12'); | |
| $('#one').parent().addClass('col-md-6'); | |
| $('#add').addClass('hide'); | |
| $('.panel_row').append('<div class="panel panel-default" id="two"> | |
| <div class="panel-heading">Title <button type="button" id="remove" class="pull-right">-</button> | |
| </div> | |
| <div class="panel-body">Content here..</div> | |
| </div> | |
| </div>'); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment