jQuery: put a default value in all empty textboxes
<p><sub><em>Textbox refers to <code>&lt;input type="text"&gt;</code> in this question.</em></sub></p>

<p>For each textbox with a given class i would like to check if the value equals <code>''</code>, and if it does I want to make the value <code>'0'</code>. I would like to do this as soon as the page is loaded.</p>

<p>This is the closest I've got now:</p>

<pre><code>$(document).ready(function() {
  if ($('.myclass').val() == '') $('.myclass').val('0');
})
</code></pre>

<p>The problem here is that this code will give all my textboxes (with <code>class="myclass"</code>) the value <code>'0'</code> as soon as one of them is empty. I know this is the expected behaviour given the code I use now, but I'm pretty new to jQuery and I haven't really got the hang of the selectors yet. How would I solve this? Do I need to create a separate function to do the check on one element and then call that for each of the elements that apply to the selector? If so, how would I do this?</p>
