1

I`m having problem with javascript OR operator. Take a look at following code:

$(trail1.node,circle1.node,text1.node).qtip({
            content: {
                text: 'this is a test',
                title: {text: 'test', button: 'close'}
            },
            position: {
                target: 'mouse'
            },
});

From this example .qtip applies only to the first variable, I want it applied to trail1, circle1 and text1. So whats wrong? Im using RaphaelJS and qtip2 if this knowledge is necessary :)

Dexygen
  • 12,287
  • 13
  • 80
  • 147

1 Answers1

2

What you have is the comma operator, not the logical OR operator. The comma operator always returns the result of the last expression in the list.

Assuming those are DOM elements, you'd instead pass them in an Array.

$([trail1.node,circle1.node,text1.node]).qtip(...

If they're referencing selector strings, you'd build a comma separated string. You can still use an Array for this with .join().

$([trail1.node,circle1.node,text1.node].join()).qtip(...

This will create a comma separated list of selectors, which makes a "multiple selector".

I Hate Lazy
  • 47,415
  • 13
  • 86
  • 77