2

I have:

var outcome = $('#outcome') ;

With one outcome "#outcome" but i want to have two outcomes

i have tried

var outcome = $('#outcome #outcome2') ;
Ben Everard
  • 13,652
  • 14
  • 67
  • 96
Ma9ic
  • 1,107
  • 4
  • 16
  • 30
  • Removed the Java tag from the question ;-) --> http://stackoverflow.com/questions/245062/whats-the-difference-between-javascript-and-java – Ben Everard May 15 '12 at 10:44

1 Answers1

6

Separate the selectors with a comma:

var outcome = $('#outcome, #outcome2');

What you currently have is looking for an element matching #outcome2 that is a descendant of an element matching #outcome.

This is documented under "multiple selector" in the jQuery API. As noted on that page, an alternative is to use the add method (but I would definitely recommend sticking with the multiple selector in this case):

var outcome = $('#outcome').add('#outcome2');
James Allardice
  • 164,175
  • 21
  • 332
  • 312