0

I used jQuery clone() to copy a <div>.

The code then clears any <input> values in the clone before inserting it back into the DOM using element.val('').

However, after clearing the <input> values, the value attribute of the new element still has the copied value.

This is demonstrated in the screenshot below. The selected <input> element shows no text. However, you can see in the markup that the value attribute still has the value from the original element that was cloned (shown in the previous row).

enter image description here

How can the value attribute not match what is in the textbox?

Jonathan Wood
  • 65,341
  • 71
  • 269
  • 466
  • 1
    The `value` property is not the same as the `value` attribute. The attribute is the initial default value, and it's used if you call `form.reset()`. – Barmar Oct 26 '21 at 22:02
  • @Barmar: Wow, that's new to me then. For some reason, the client-side validation isn't firing when it's empty. So I thought maybe it was picking up the value attribute. – Jonathan Wood Oct 26 '21 at 22:05

0 Answers0