Another option would be to use the metadata plugin: http://plugins.jquery.com/project/metadata
- Richard On Tue, Aug 25, 2009 at 7:59 AM, AMP <ampel...@gmail.com> wrote: > > Good one, > Thanks > > On Aug 24, 4:02 pm, James <james.gp....@gmail.com> wrote: > > Since "region" is not a valid HTML attribute, other ways is to set an > > ID on the element and use that as a reference to data stored elsewhere > > (e.g. a Javascript array or object). > > Depending on whether you have a lot of data or not. Assuming you have > > many onclicks on your page, here's another way to do it. > > > > <script> > > // JS object > > var myData = {id1:'US', id2:'Europe', id3:'Antarctica'}; > > > > $("div.clickme").click(function() { > > var id = this.id; // 'id1' or 'id2' or 'id3' > > alert(myData.id); // 'US' or 'Europe' or 'Antarctica' > > // alert(myData[id]); // same as above}); > > > > </script> > > > > <div id="id1" class="clickme">Text 1</div> > > <div id="id2" class="clickme">Text 2</div> > > <div id="id3" class="clickme">Text 3</div> > > > > On Aug 23, 2:40 pm, AMP <ampel...@gmail.com> wrote: > > > > > > > > > This is the way I was thinking so could you give me another example > > > without attributes (Just so I could learn a different way). > > > Thnaks > > > > > On Aug 23, 8:05 pm, MorningZ <morni...@gmail.com> wrote: > > > > > > MANY ways to do this, with this being one of them > > > > > > <button id="parsetablebutton" region="<?php echo $Region ?>">Some > > > > Text</button> > > > > > > then > > > > > > $("#parsetablebutton").click(function() { > > > > var region = $(this).attr("region"); //<<-- the value from > > > > PHP > > > > > > }); > > > > > > again, that's just one way of many > > > > > > On Aug 23, 6:04 pm, AMP <ampel...@gmail.com> wrote: > > > > > > > Hello, > > > > > I was using this: > > > > > onClick="parsetable('<?php echo $Region ?>')" > > > > > > > but now I want to use the JQuery: > > > > > $("#parsetablebutton").click( function() { > > > > > > > How do I pass the parameter to the function? > > > > > Would I set an attribute and read it with[att=XXX] where the > attribute > > > > > is the echo'd $Region or is there a better way? > > > > > Thanks- Hide quoted text - > > > > > > - Show quoted text -- Hide quoted text - > > > > - Show quoted text -