Re: [jQuery] Selection logic

2009-11-10 Thread Michel Belleville
2009/11/10 Karl Swedberg > On Nov 10, 2009, at 7:58 AM, Michel Belleville wrote: > > >- $(el).parents('div').get(0).addClass('myClass'); // should work, may >be a testing error (just tested it, worked for me) > > Interesting that this one worked for you. I wouldn't expect it to, since > t

Re: [jQuery] Selection logic

2009-11-10 Thread Karl Swedberg
On Nov 10, 2009, at 7:58 AM, Michel Belleville wrote: $(el).parents('div').get(0).addClass('myClass'); // should work, may be a testing error (just tested it, worked for me) Interesting that this one worked for you. I wouldn't expect it to, since the .get() method is supposed to return a DOM e

Re: [jQuery] Selection logic

2009-11-10 Thread Michel Belleville
- $(el).parent('div'); // didn't work because .parent()(only matches the direct parent, not any ancestors) is not the same as .parents() (matches all ancestors) - $(el).parents('div'); // returning all

Re: [jQuery] Selection logic

2009-11-10 Thread waseem sabjee
var parent_element = $(".child).parents('div'); On Tue, Nov 10, 2009 at 12:16 PM, Savageman wrote: > Hello, > > I'm using jQuery but am not really used to it (Mootools' user > here...). > > I was trying to add a class to the first parent "div" of an element. > Here is how I proceeded in the firs