Ad

JQuery Return Multiple Function

- 1 answer

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)

Ad

Answer

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];
Ad
source: stackoverflow.com
Ad