javascript - Get the hidden div element html content with the style -


i have hidden div , trying div styles. when append div below code getting appended out styles. please suggest other way.

    var warningmessage = $('#warningdiv').html()   function postsettings() {     var frm_data = $("#myform").serialize();     $.ajax(         {             type: "post",             url: "path",             data: frm_data,             success: function (successdata) {                 var warningmessage = $('#warningdiv').html();                 **$(warningmessage).insertafter("#mydiv"); // not showing warning message css styles .**              },          }); } 

this gives html without style, want styles , need append div dynamically. div:

<div class="note note-warning" id="warningdiv" style="display:none">     <div class="block-warning">         <h4 class="block"> <i class="demo-icon icon-attention-1 fa"></i> warning! header goes here</h4>         <p> test</p>     </div> </div> 

please try below code snippet.

for testing purpose have removed 'display:none' property div 'warningdiv'.

<!doctype html> <html> <head>     <script src="https://code.jquery.com/jquery-1.10.2.js"></script>     <script>         $(function () {          });         function postsettings() {             $($("#warningdiv").prop('outerhtml')).insertafter("#mydiv");         }     </script> </head> <body>     <div class="note note-warning" id="warningdiv" style="color: red;">         <div class="block-warning">             <h4 class="block"><i class="demo-icon icon-attention-1 fa"></i>warning! header goes here</h4>             <p>test</p>         </div>     </div>     <div>         <input type="button" onclick="postsettings()" value="click here call postsettings()" />         <div id="mydiv">mydiv</div>     </div>  </body> </html> 

i have removed 'display:none' property newly created div.

<!doctype html> <html> <head>     <script src="https://code.jquery.com/jquery-1.10.2.js"></script>     <script>         $(function () {          });         function postsettings() {             $($("#warningdiv").prop('outerhtml')).insertafter("#mydiv").show();         }     </script> </head> <body>     <div class="note note-warning" id="warningdiv" style="display: none;">         <div class="block-warning">             <h4 class="block"><i class="demo-icon icon-attention-1 fa"></i>warning! header goes here</h4>             <p>test</p>         </div>     </div>     <div>         <input type="button" onclick="postsettings()" value="click here call postsettings()" />         <div id="mydiv">mydiv</div>     </div>  </body> </html> 

let me know if concern.


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -