var li = $('ul li');

li.bind('click', function() {
        alert(li.index(this));
});

...works for me. Also, if you are calling jQuery on the same set of
objects more than once, it is wise to set a reference to it instead of
re calling it more than once. Instead something such as this:

$('ul li').bind('click', function() {
        alert($('ul li').index(this));
});

This makes your code faster - which is unnoticeable in this example,
but when you have 2000 lines of it going on, you bet your sweet ass :)
- and easier to change in the future.

-Trey

On Feb 10, 3:37 pm, Pedram <pedram...@gmail.com> wrote:
> I came back to my COde An I found your code fit in mine I am not going
> to use rowIndex because My Plugin it should work for every selector so
> what I atually want to do to get the selector name and bind an event
> to it and sent it to a function and also pass the index to the
> function and the reason I'm doing this is because I have some
> recursive functions in it and I badly needed this to be done .
>
>   var RowSet={
>     close:false,
>         eventClass:"eventClass",
>         eventType:"click",
>         ActionSelector:"tr"
>   }
>
>   function clickFunc(e){
>           console.log(e.data.Index);
>   }
>   $.fn.RowEffectByEvent=function(options){
>         RowSet = jQuery.extend({},RowSet,options);
>         return this.each(function(){
>           oo=$(this);
>           var k=(settings.header) ? ":not(:first)" : "";
>           $(RowSet.ActionSelector+k,oo).each(function(index){
>                         
> $(this).bind(RowSet.eventType,{Index:index},clickFunc);
>           });
>         });
>   };
>
> this is what I actually wanted to do thanks a lot guys you helped me
> alot and also RobG A appreciate it . thanks for the Tutorial also.
>
> On Feb 9, 1:26 pm, Ricardo Tomasi <ricardob...@gmail.com> wrote:
>
> > $("table tr").each(function( index ){
> >   $(this).click(function(){
> >      alert('I am TR number ' + index);
> >   });
>
> > });
>
> > the index() function works on a collection of elements, so you'd have
> > to get them first:
>
> > $('table tr').click(function(){
> >    alert( $(this).parent().children().index(this) );
>
> > });
>
> > On Feb 9, 5:48 pm, Pedram <pedram...@gmail.com> wrote:
>
> > > How COme we could not have access inside the BIND with THIS !! I'm
> > > Confused
>
> > > On Feb 9, 7:16 am, Pedram <pedram...@gmail.com> wrote:
>
> > > > I check these two solutions it didn't work ...
>
> > > > On Feb 8, 11:42 pm, RobG <rg...@iinet.net.au> wrote:
>
> > > > > On Feb 9, 4:54 pm, Pedram <pedram...@gmail.com> wrote:
>
> > > > > > Dear folk,
> > > > > > I want to get the index of the TR and send it to the Function , I
> > > > > > don't know how to it . this is what I'm trying to do
>
> > > > > > $("table 
> > > > > > tr").bind("click",{IndexName:$(this).index(this)},clickFunc)
>
> > > > > The DOM 2 HTML TR.rowIndex property should do the job.
>
> > > > > --
> > > > > Rob

Reply via email to