TL, dr? jsFiddle Demo
I have a scenario where I need to re-release the jquery selector because dom is changing. The selector is not trivial.
$("#protocol :first-child").nextUntil('.sampleDetails','.detailHolder')
To do this, I tried to break it into pieces and save them for reuse:
var selector = []; selector.push("#protocol :first-child"); selector.push("nextUntil"); selector.push(['.sampleDetails','.detailHolder']);
And so, when I needed to create a selector, I could use
$(selector[0])[selector[1]](selector[2]);
However, the nextUntil argument requires two parameters. Using an array does not work, and using ".sampleDetails", ". DetailHolder" does not work. I tried using call and apply , but got the error message "Uncaught TypeError: Object [object Array] has no method 'pushStack' " .
What is the correct way to store this type of selector chain?
source share