1

Is it possible to add the current element as an entry to the result of Element.select?

Background: I want to apply a specific class name to an element and some of its children. So something like myElem.select('this, .childElements').invoke('addClassName', 'alice') would be cool - but, of course, this isn't a valid keyword here.

Prototype.js Docs for Element.select

1 Answer 1

1

Unfortunately that behavior is not the target of the select() method. However you can get the results you are looking for by going up to myElem parent element.

myElem.up().select('.childElements, .parentElement').invoke('addClassName','alice')

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.