Tuesday, December 1, 2009

Re: [jQuery] super easy jquery question

you can do this.

                    // reset input type text
                    $('#form_id input[type=text]').each(function(){ this.value = ''; });
                    // reset textarea
                    $(''#form_id textarea').each(function(){ this.value = ''; });
                    // reset select
                    $('#form_id select').each(function(){
                        $(this).find('option:first').attr('selected', 'selected').parent('select');
                    });

Best regard,
Paisal.

mike wrote:
After I have processed a user request from a form submittal, I want to remove the text from a text <input> field.   With JQuery, how do I do that?  The input field has the id of #subject.  I've tried the following, but to no avail.  (I clearly don't understand jquery).  Please help.  $('#subject').val()=""; $("#subject").text('');  $("#subject").text().replace("");     

No comments: