Problem with attr('id')

Problem with attr('id')

Hi,

I'm trying to get the id of an element into a hidden text field.

Here is my code:
  1.        $('span.textHolder').click(function(){
                temp = $(this).html();
                $('#parentname').val(temp);
                parentli=$('li', this.parentNode);
                //alert(parentli.attr('id'));
                $('#parentid').val(parentli.attr('id'));
            });





parentid is my target field, parentli the element which I want to get the id. I tested using alert, I can display the inner html using html, I can display the class using attr('class'). But I just can't get the id.

And yes I'm sure my element has an id, here is the code:
  1. <li id="li1" class="treeItem" >
Hope someone can help, I couldn't find any topic on google...

Thanks,

Cyril