jQuery: Selecting Previous Element from Click Event In Loop
<p>Forgive me if this question has been asked before but I am new to jQuery and am having trouble even describing my problem. I have a loop in a php page that looks something like this:</p>

<pre><code>foreach ($blahs as $blah) {
    echo '&lt;p class="title"&gt;'.$blah-&gt;title.'&lt;/p&gt;';
    echo '&lt;input/&gt;';
    echo '&lt;input/&gt;';
    echo '&lt;div class="delete-button"&gt;&lt;img /&gt;&lt;/div&gt;';
}
</code></pre>

<p>What I am trying to accomplish is the replacement of <code>.$blah-&gt;title.</code> with the phrase "Delete this title?" in the closest preceding <code>&lt;p&gt;</code> element to whichever <code>&lt;div class="delete-button"&gt;</code> is clicked. To do this I have some jQuery at the top of the page like so:</p>

<pre><code>&lt;script type="text/javascript"&gt;
    jQuery(document).ready(function() {
        jQuery(".delete-button").click(function() {
            jQuery(this).prev('.title').html("Delete this title?");
        });
    });
&lt;/script&gt;
</code></pre>

<p>However, this does not work. If I remove the <code>.prev('.title')</code> it replaces the html of the div so I know its working on some level but I cannot manage to get it to replace the html of the previous <code>&lt;p class="title"&gt;</code>. Thanks for your help.</p>
