我想用jQuery點擊一個輸入字段時,將一個名爲'focused'的類添加到父li。如何給li添加一個類,它可能是jquery輸入的第一,第二或第三個父項?
<form action="http://localhost/daikon2/index.php/projects/admin/newproject" method="post"><ul id="createproject">
<li id="proname" class="">
<label for='project_name'>Project Name</label>
<div><input type="text" name="project_name" value="" id="project_name" size="20" /></div></li>
<li id="tothou" class="" >
<label for='total_hr'>Total hour</label>
<div><input type="text" name="total_hr" value="" id="total_hr" size="10" /></div>
</li>
<li id="act" class=""><label for="active">Active</label><div><span>Yes<input type="radio" name="active" value="1" checked="checked" id="active" /></span><span>No<input type="radio" name="active" value="0" /></span>
</div>
</li>
<li id="by" class""><label for='created_by'>By</label>
<div><select name="created_by">
<option value="admin">admin</option>
<option value="admin2">admin2</option>
</select></div>
</li><li id="noteli" class=""><label for='note'>Note</label>
<div><textarea name="note" cols="90" rows="12" id="note" ></textarea></div>
</li>
<li>
<input type="hidden" name="id" value="6" />
</li>
<li id="submitbtn" class""><input type="submit" name="submit" value="Create New Project" /></li>
</form>
</ul>
在此先感謝。
感謝筆記的詳細信息。 – shin 2010-10-04 12:59:13