Daemach2's solustion would do it, and if your <li> elements are nested
inside other <li> elements, you may wish to restrict the parents() method to
match only the first <li> up the tree by using
$(this).parents('li:first').addClass('on'); instead, that way you won't set
addClass('on') for more than one <li>
George
Daemach2 wrote:
>
>
> You should be able to do:
>
> $(function()
> {
> $("fieldset").find("input,select,textarea,option").focus
> (function()
> {
> $(this).parents('li').addClass('on');
> }
> )
> .blur
> (function()
> {
> $(this).parents('li').removeClass('on');
> }
> );
>
> });
>
> On May 24, 9:48 pm, fambizzari <[EMAIL PROTECTED]> wrote:
>> Hi everyone,
>>
>> Imagine the following HTML scenario:
>>
>> <li>
>> <label for="title_new">Title</label>
>> <div class="input"><input name="title_new" id="title_new"/></div>
>> </li>
>> <li>
>> <label for="message_new">Message</label>
>> <div class="input">
>> <div>
>> <div>
>> <div>
>> <input name="message_new"
>> id="message_new"/>
>> </div>
>> </div>
>> </div>
>> </div>
>> </li>
>>
>> How could i modify the following jquery code so that it effects the
>> parent <li> and and not the parent node:
>>
>> $(function()
>> {
>> $("fieldset").find("input,select,textarea,option").focus
>> (function()
>> {
>> this.parentNode.className = "on";
>> }
>> )
>> .blur
>> (function()
>> {
>> this.parentNode.className = "";
>> }
>> );
>>
>> });
>>
>> I hope that makes sense.
>
>
>
--
View this message in context:
http://www.nabble.com/Finding-a-parent-list-item.-tf3814215s15494.html#a10798868
Sent from the JQuery mailing list archive at Nabble.com.