Note that there are some explanatory texts on larger screens.

plurals
  1. POJQuery how to clear all the input:textfields of a .class on a form. Not working for me
    text
    copied!<p>I have a form, the first .class has 5 input:text boxes in it. I want to be able to clear all the text boxes with the click of a button. I've tried it a few ways and it's not working... here's what I've done.... (FYI, I have more classes in the form so I can't use .reset.</p> <h2>The Form...</h2> <pre><code>&lt;table class="orderLine1 formFont" width="900"&gt; &lt;tr&gt; &lt;td width="395"&gt;Product Name:&lt;br&gt;&lt;input class="ProductName" type="text" size="65"&gt;&lt;/td&gt; &lt;td width="97" class="formFontDisabled"&gt;Prod ID:&lt;br&gt;&lt;input class="Product_ID ffd" type="text" size="5" disabled&gt;&lt;/td&gt; &lt;td width="78" class="formFontDisabled"&gt;UPC:&lt;br&gt;&lt;input class="UPC ffd" type="text" size="13" disabled &gt;&lt;/td&gt; &lt;td width="67" class="formFontDisabled"&gt;List Price:&lt;br&gt;&lt;input class="ListPrice ffd" type="text" size="7" disabled&gt;&lt;/td&gt; &lt;td width="67"&gt;WholeSale:&lt;br&gt;&lt;input class="WholeSalePrice ffd" type="text" size="7" disabled&gt;&lt;/td&gt; &lt;td width="56"&gt;Quantity:&lt;br&gt;&lt;input class="qty addLine" type="text" size="7"&gt;&lt;/td&gt; &lt;td width="60" class="formFontDisabled"&gt;Line Total:&lt;br&gt;&lt;input class="subTotal ffd" type="text" size="10" disabled&gt;&lt;/td&gt; &lt;td width="44"&gt;&lt;button class="OFDeleteButton"&gt;Delete&lt;/button&gt;&lt;button class="OFClearLine" &gt;OFClearLine&lt;/button&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; </code></pre> <h2>The Script Test # 1</h2> <pre><code> $(document).ready(function(e) { $(function clearFirst() { $('.orderLine1').find(':input').each(function() { switch(this.type) { case 'text': $(this).val(''); break; } }); }); $('.OFClearLine').click(function(e) { clearFirst(); }); }); </code></pre> <h2>The Script Test # 2</h2> <pre><code> $(function(){ $('.OFClearLine').bind('click', function(){ $('.orderLine1').reset(); }); }); </code></pre> <p>More info: OFClearLine is the class for the button I want to use &amp; orderLine1 is the class of the form.</p> <p>Thanks in advance!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload