Can you please take a look at this demo and let me know why I am not able to reordering the buttons in .popover-content class. What I would like to do is different order of presenting the button on each click on #pop and as you can see I am using
$("#pop").on("click", function(){ $('.popover-content > button').each(function() { $(this).prependTo(this.parentNode); }); }); but it is not reordering the buttons!
var appcontent = '<button class="btn btn-success btn-block">Item 1</button><button class="btn btn-warning btn-block">Item 2</button><button class="btn btn-info btn-block">Item 3</button>'; $("#pop").popover({ html: 'true', title: "<span class='date-title'>Hello</span>", content: appcontent }).on('shown.bs.popover', function() { var popup = $(this); $(this).parent().find("div.popover .close").click(function() { popup.click(); }); }); $("#pop").on("click", function() { $('.popover-content > button').each(function() { $(this).prependTo(this.parentNode); }); }); body {padding:100px;} .popover {min-width:250px;} <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script> <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" /> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script> <div class="container"> <h3>Bootstrap 3 Popover Reordering Content Example</h3> <button class="btn btn-default" id="pop">POP UP</button> </div>
detach()then?!.detach()is necessary, as prepending the node elsewhere in the DOM implicitly detaches it. @Behseini what does happen? Are there errors? Does anything change?