.parernts('.switch')[0]
Sorry about the typo. Should be .parents('.switch')[0]
--Karl
On Oct 5, 2007, at 1:53 PM, Karl Swedberg wrote:
Forgive me if this has been answered already. Seems like I'm
getting emails dumped into my mail client in a random order.
To use a DOM method on a jQuery object, you first need to convert
that object. Fortunately, it's easy to do by adding either [0]
or .get(0) after the selector:
alert($(this).parent(".switch")[0].className);
Also, your selector finds only the direct parent. If you need to go
up more than one level, you could use .parernts('.switch')[0]
instead (with an "s" at the end).
--Karl
_________________
Karl Swedberg
www.englishrules.com
www.learningjquery.com
On Oct 5, 2007, at 9:23 AM, dan wrote:
I'm just starting with jquery and I guess I'm missing an important
piece because my first tries aren't working:
$('.switch :radio', this).each(function(){
$(this).click(
function(event){
alert($(this).parent(".switch").className);
});
});
//when I click the radio, find the .switch parent and alert it's
classes.
Do regular DOM methods and properties work on jquery objects?