Steve Kim
Steve Kim

Reputation: 5601

jQuery return multiple function

so, i have the following js:

function RHL(a,b,c)
{
  return rx.removeClass(a).addClass(b); 
  return rhpfc.html(parseInt( rhpfc.html() ) -1 );      
} 

I am having a bit of difficult time with the formatting and syntax.

How do I combine both lines under one return. Also, I want to have two options: -1 or +1. So, I thought I would make - or + as c.

what kind of bracket do I need? (ie. 'c'1)

Upvotes: 1

Views: 45

Answers (1)

I wrestled a bear once.
I wrestled a bear once.

Reputation: 23389

function RHL(a,b,c){
  return [
    rx.removeClass(a).addClass(b), 
    rhpfc.html(parseInt( rhpfc.html() ) -1 )
   ];      
} 

then you will need to use the index 0 or 1 to use the return value..

var rx = RHL(a,b,c)[0];

or

var rhpfc = RHL(a,b,c)[1];

Upvotes: 3

Related Questions