I'm a little unclear about usage of $(this). I have this function
that currently works but the idea is that I can reuse this for many
instance (I'll put a callback into this later that will be different
for each time it's used). What it does (for the moment), is simply
toggle (highlight) the selected element in a list (LI):
jQuery.fn.tabpost = function()
{
$(this).click(function()
{
check = $(this).attr('tabindex');
$('.ajx-thumbs li').each(function() // this line is the problem
{
$(this).compare(check, $(this).attr('tabindex')); //
sets the
class to 'active' if true or removes it...
});
return false;
});
}
Works just right, expect that I have '.ajx-thumbs li' specified - I
need to have the function know what it's dealing with here (as it
goes through the list). The function is called into action in a
document ready...
$('.ajx-thumbs li').tabpost();
This is what the html looks like...
<ul class='listed ajx-thumbs'>
<li id='tab1' tabindex='1'>100</li>
<li id='tab2' tabindex='2' class='active'>200</li> // active at page
output
<li id='tab3' tabindex='3'>300</li>
<li id='tab3' tabindex='4'>Original</li>
</ul>
This would be my first actual Jquery function...I could use some
pointers here I bet. ;)
Any thought?
Thanks...
PS: when completed it will be something like...
$('.ajx-thumbs li').tabpost(callback1);
$('.ajx-image li').tabpost(callback2);
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/