Select previous paragraph tag under multiple scenarios
<p>I'm new to jQuery and wondering if there's an elegant way to select tags under two different DOM scenarios. I'm using jQuery to validate a form and add an error class to a paragraph tag (which bolds the text and highlights it in red) if the input value is empty. Some of the paragraph and input tags exist in the DOM like this:</p>

<pre><code>&lt;td&gt;&lt;p&gt;Name:&lt;/p&gt;&lt;/td&gt;&lt;td&gt;&lt;input type="text" name="field_name"&gt;&lt;/td&gt;
</code></pre>

<p>While others exist like this:</p>

<pre><code>&lt;td&gt;&lt;p&gt;Name:&lt;/p&gt;&lt;input type="text" name="field_name"&gt;&lt;/td&gt;
</code></pre>

<p>My jQuery function so far looks like this:</p>

<pre><code>$("#form_id").submit(function() {
    var answer = true;
    $(this).find(".required").map(function() {
        if(!$(this).val()) {
            $(this).closest("td").prev("td").find("p").addClass("form_error");
            answer = false;
        }
        else {
            $(this).closest("td").prev("td").find("p").removeClass("form_error");
        }
    });
    return answer;
});
</code></pre>

<p>The key line is this:</p>

<pre><code>$(this).closest("td").prev("td").find("p").addClass("form_error");
</code></pre>

<p>Which is an explicit selection of p tags under my first DOM scenario, but of course it fails on the second. I'm looking for a single line of code that will select p tags under both scenarios. I've been playing with <code>.prev("p")</code> but have not figured it out so far. Is there a way to do this?</p>
