On Fri, 2008-02-08 at 08:11 -0800, cbmtrx wrote: > I've just barely started getting my feet wet with jquery, so please > bear with this novice's question... > > With a javascript function you can accept vars like this: > > function doSomething(number, name) { > //Do something with them > } > > From an href in the HTML like this: > <a href="javascript:doSomething('1234','john');>Click me</a> > > [...] > > Any suggestions? >
If you are able to change your function 'doSomething' a little bit, you may also use the jQuery method 'bind' to have custom parameters passed with the event. For example: ========== function doSomething(evt) { var num = evt.data.num; var name = evt.data.name; // do whatever } $("a.link1").bind("click", {num:1234, name:'john'}, doSomething); $("a.link2").bind("click", {num:4567, name:'harry'}, doSomething); $("a.link3").bind("click", {num:8912, name:'dick'}, doSomething); ========== if you want it less verbose, you can use an array as your data parameter: ========== function doSomething(evt) { var num = evt.data[0]; var name = evt.data[1]; // do whatever } $("a.link1").bind("click", [1234, 'john'], doSomething); $("a.link2").bind("click", [4567, 'harry'], doSomething); $("a.link3").bind("click", [8912, 'dick'], doSomething); ========== Tim.