How to add a class to li which could be the first, second or third parent of input with jquery?
<p>I would like to add a class called 'focused' to a parent li when I click a input field with jquery.</p>

<pre><code>&lt;form action="http://localhost/daikon2/index.php/projects/admin/newproject" method="post"&gt;&lt;ul id="createproject"&gt;
&lt;li id="proname" class=""&gt;
&lt;label for='project_name'&gt;Project Name&lt;/label&gt;
&lt;div&gt;&lt;input type="text" name="project_name" value="" id="project_name" size="20"  /&gt;&lt;/div&gt;&lt;/li&gt;

&lt;li id="tothou" class="" &gt;
&lt;label for='total_hr'&gt;Total hour&lt;/label&gt;
&lt;div&gt;&lt;input type="text" name="total_hr" value="" id="total_hr" size="10"  /&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li id="act" class=""&gt;&lt;label for="active"&gt;Active&lt;/label&gt;&lt;div&gt;&lt;span&gt;Yes&lt;input type="radio" name="active" value="1" checked="checked" id="active" /&gt;&lt;/span&gt;&lt;span&gt;No&lt;input type="radio" name="active" value="0"  /&gt;&lt;/span&gt;

&lt;/div&gt;
&lt;/li&gt;
&lt;li id="by" class""&gt;&lt;label for='created_by'&gt;By&lt;/label&gt;
&lt;div&gt;&lt;select name="created_by"&gt;
&lt;option value="admin"&gt;admin&lt;/option&gt;
&lt;option value="admin2"&gt;admin2&lt;/option&gt;
&lt;/select&gt;&lt;/div&gt;
&lt;/li&gt;&lt;li id="noteli" class=""&gt;&lt;label for='note'&gt;Note&lt;/label&gt;
&lt;div&gt;&lt;textarea name="note" cols="90" rows="12" id="note" &gt;&lt;/textarea&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;input type="hidden" name="id" value="6" /&gt;

&lt;/li&gt;
&lt;li id="submitbtn" class""&gt;&lt;input type="submit" name="submit" value="Create New Project"  /&gt;&lt;/li&gt;
&lt;/form&gt;
&lt;/ul&gt;
</code></pre>

<p>Thanks in advance.</p>
