Problem passing variables into JQ

Problem passing variables into JQ

This probably seems pretty trivial to you experts but I just don't know why it doesn't work and would like a nudge in the right direction please.

I have a sllide and fade that works great - no problems. I am firing it with a function call from the HTML like so;

<a href='#' onClick='sfade('#s1'); return false;>


as you see I am passing the div to be faded(and slid) as a variable. Works great. The receiving function is:

var str='';

function sfade(str){
       $(str).slideFadeToggle(1000);
};


You will see that I have the slide/fade times to last 1000ms.

What I would like to do is pass this argument into the function from the function call - trouble is it just does not work.

I am trying:

<a href='#' onClick='sfade('#s1', 1000); return false;>


With the js code:

var str='';
var num=0;

function sfade(str, num){
       $(str).slideFadeToggle(num);
};


The webpage retuns no error, but there is no slide fade action either.

Why can't I pass variables into the function?