Yes, you can. "this" refers to the HTMLElement in the context of an event handler. Though, your syntax is a bit wonky, should be:
$('#slickbox' + this.id).toggle(400); On May 6, 4:13 am, Christos <tsam...@gmail.com> wrote: > Hi all, > > I wanted to ask whether we can use "this" for selecting in jquery. > What i want to do is to have one toggle function for many objects. > the fuction i use now is the above > > $('a#slick-toggle').click(function() { > $('#slickbox').toggle(400); > return false; > }); > > which toggles the "slickbox" when the "slick-toggle" is clicked. The > problem that i have is that i want to have many objects like "slick- > toggle1" "slickbox1", "slick-toggle2" "slickbox2". One way is to make > different function for each "a", but because the html is created > dynamically, i don't know from the beggining how many i will have. So > what i ask how i can do something like that > > $('a').click(function() { > $('#slickbox+this.id').toggle(400); > return false; > }); > > where this.id is going to be the id of the "a" i click and "#slickbox > +this.id" is the id of the object i want to hide. > > Christos