How to clear all textbox fields on parent page using jquery

This is their way to clear all text field values ​​in the parent form using jquery or javascript. Now I clear all the fields using

var parentDoc1 = window.opener.document; parentDoc1.getElementById(id).value=""; 
+4
source share
8 answers

To clear all text fields, you can use this:

 $(parentDoc1).find('input[type=text]').val(''); 

If some text fields (for example, text fields with the mytextboxclass class, with mytextboxid id, etc.) should not be cleared, then you can use :not in your selector to exclude such:

 $(parentDoc1).find('input[type=text]:not(.mytextboxclass,#mytextboxid)').val(''); 
+4
source

You can also use

 $('input:text').val(''); 
+2
source

use class throughout the input field ....

try it.

  $('input.className').val(''); 

the script is here

OR

but this puts the value as empty for all input fields in the document

 $('input[type="text"]').val(''); 
0
source

How to do this to clear all text fields:

 $('input[type="text"]').val(''); 
0
source

This clears the values ​​of all text areas that are in the parent with id parent .

 $('#parent').children('textarea').val(''); 

Here is an example http://jsfiddle.net/Y2t7x/1/

The important thing is that the script clears only text areas that are direct siblings from #parent and not nested.

If you want to reset the values ​​of the text areas that belong to the siblings of the parent, you must replace children with find .

If you want the script to work with text inputs, use:

 $('#parent').children('input[type=text]').val(''); 

or

 $('#parent').find('input[type=text]').val(''); 

Again depending on your needs.

0
source

Do you want to select the page content in another tab / window? or do you want the contents of the parent page to call your context that you are inside an iframe? if it is the last, do not use

 window.opener.document; 

use instead

 window.parent.document; 
0
source

And if you use jQuery anyway, you can just use .reset () instead of .val ('').

0
source

You can also create a function in the parent window and call it from the child window. In the child window, call the parent function, as shown below.

 <script> function ClearFromChild(ARGS) { window.opener.clearinparent(ARGS); } </script> 

now just declare the clearinparent function in the parent window, and you clearinparent done.
Cheers

0
source

All Articles