> Correct me if I'm wrong. But this scenario won't catch an element with the 
> class "name1 name2":
> el.getParent('.name1')
> This is looking for the exact name. So, this won't work as the method I'm 
> looking for....?

el.getParent('.name1.name2')  (no space!) will get for You only
elements with both classes, el.getParent('.name1') will get all
elements with class name1, el.getParent(':not(.name2).name1') get You
elements with name1 and not name2. Works also with Sanford version
witch does the same and is better.

http://jsfiddle.net/S3aaL/

> 2. For the method Sanford provided - parentWithClassById(id) - I'm concerned 
> about some potential speed issues on a page with potentially thousands of 
> elements (and potentially in a loop).

I believe for CSS it is in most cases faster to walk inside DOM then
reverse.


> AND, the $$() method only acts on the whole document - you can't get 
> descendants from a particular element with it, correct?

Yes, You can, just add it to the selector.
Or You can use .getElements.

> Also, parentWithClassById() won't work if the element doesn't have an id.
> Thanks for letting me pick your brains. BTW, I'm using MT 1.2.5.

var tempId = String('id-'+$time());
elem.set('id', tempId);


Cheers,

Reply via email to