Some new selectors...intrv(), intrvR(), slct() and slctR()
Hello, everybody...
I'm new on the forum, and also new with the using of JQuery.
There is a long time that I want learn JQuery, but I will not have the time to do.
So the last week, ones of my friends ask me if I'll know JQ and if I could help him...
I answer him, no...I don't know JQ for the moment... But wait a lot I will take a look on it this night
and we will see it tomorrow... We resolves the problem together the next day and seduced by possibilities
of JQ I'm continuing to study...
Now, I would like to purpose you some new selectors that I've add to my library.
--The 'Interval' selectors:
intrv() and intrvR()
With this selectors you can match a range of object
ex:
- $('td:intrv(3,7)').css({'background-color':'#cccccc'});
- $('td:intrvR(3,7)').css({'background-color':'#cccccc'});
The first line will match the cells 3 to 7 of all the tables in the page.
The second one will do the inverse.
--The 'Selection' selectors:
slct() and slctR()
with this selectors you can match a defined selection of object
ex:
- $('td:slct(3,7,2,8)').css({'background-color':'#cccccc'});
- $('td:intrvR(3,7,2,8)').css({'background-color':'#cccccc'});
The first line will match the cells 2, 3, 7 and 8 of all tables in the page.
and the second line will do the inverse exactly as the two others selectors.
The code:
on the line 3655 of the JQ library replace the line by this:
- POS: /:(nth|eq|gt|lt|first|last|intrvR|intrv|slctR|slct|even|odd)(?:\(([\d,]*)\))?(?=[^\-]|$)/,
on the line 4007 add this:
- intrv: function(elem, i, match){
intr=match[3].split(',');
return i >= intr[0] - 0 && i<=intr[1] -0;
},
intrvR: function(elem, i, match){
intr=match[3].split(',');
return i <= intr[0] - 1 || i>=intr[1] -0 +1;
},
slct: function(elem, i, match){
sl=match[3].split(',');
r=-1;
while(r<=sl.length-1){
r++;
if(i==sl[r]){return 1;};
};
return 0;
},
slctR: function(elem,i,match){
sl=match[3].split(',');
r=-1;
while(r<=sl.length-1){
r++;
if(i==sl[r]){return 0;};
};
return 1;
},
With the hope that's will be useful for all and it will be added to the next version of the JQ library.
I have some other ideas, but all in good time...
Thanks for reading...
.LilFrenchy.
ps: sorry for my english, i'm not an english-speaking...as mentionned in my pseudo... lol