tags:

views:

31

answers:

1

Heres the markup:

<div id='0203' class='threadWrapper'>
<div class='littleme'>

I am trying to send the id of a parent div as a parameter in jquery.get function:

$('.littleme').click(function**()**{
var id = $(this).closest("div").attr("id");
$.get("PHP/viewedThread.php", {viewedURLID: id});
});

and am getting rather lost I'm afraid.

...ammendment... $(this).closest(".threadWrapper").attr("id");

+1  A: 

I am guessing (not tested) that the closest is returning itself (".littleme") which without any id. If you need to target the parent div, try using parent or parents.


UPDATE

The Closest is acutally started from Current node, so, it is not going to look for parent but probably the next div follows.

quote from documentation

Get the first element that matches the selector, beginning at the current element and progressing up through the DOM tree

xandy
actually it is all working well now, it was just a little unoticed error on my part. cheers
kalpaitch