iyal iyal - 2 years ago 63
HTML Question

Appending outer html with input number in it

I am trying to get tbody html to append to another table. And this table have an input number in it.

<tbody class="onetable tbody">
<input type="number" value=""/>

Before appending this tbody, I change the value of the input of number, forexample 3.

However, after placing the tbody to another table, the value of input reset to 1, not 3.

var wholeTbody = $("#onetable.tbody").prop('outerHTML');


How to solve this, thanks in advance.

Answer Source

You can't get the values in the outerHTML unless you set it manually as value attribute.

var wholeTbody = $("#onetable.tbody").find("input[type='text']").attr("value",function(){
  return this.value;

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download