JQuery show / hide: How do you reset the value of a form element inside a show / hide div?

How do you reset the values ​​of the various types of form elements that are in the div when using jQuery show / hide?

+3
source share
3 answers

I'm not sure if I got your question correctly, but the following jQuery magic will find your <div>element id, hide it, find all the <input>controls in it and reset their values ​​to delete the line.

$("#myDiv").hide().find("input").val("");

, <input> (, <select> <textarea>), . reset ( , ), , .

+5

, show/hide . DOM , .

0

Resetting the values ​​of form elements will not change if they are hidden. Hide / show only change the display attribute, elements still exist in the DOM.

0
source

Source: https://habr.com/ru/post/1730554/


All Articles