0

I have a drag and drop based application doing some basic workflow stuff.

I have a save button which grabs the html of a particular div and saves it into a file. This can be loaded into the app and then work can continue on it.

I'm currently doing:

$('#mydiv').html() 

to get the html of the div that I am trying to save. This works fine apart from the fact it doesn't get any of the typed entries in any input fields. I suppose this is because the values of the input aren't really in the markup.

Is there a way of me saving the input values as part of the html?

Andrew Berry
  • 853
  • 3
  • 10
  • 25

1 Answers1

0

Use clone method---

$(document).ready(function(){
    $("button").click(function(){
        $("p").html($('#demo').clone());
    });
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<p>This is a paragraph.</p>

<div id="demo"><input type="text"></div>
<button>Copy Content</button>
Chetan
  • 944
  • 5
  • 22