Hi,
I just came across a chaining issue and raised a question about it, but given the scenario I wonder which is the best pattern to use.
I have a set of tabs, the html is very simple:
<ul class="tabs">
<li><a>Tab1</a></li>
<li><a>Tab2</a></li>
<li><a>Tab3</a></li>
</ul>
The 'li' element can be accessed via its ID, and sometimes a class'.
Say I want to set the current tab with a class of 'selected'. At the moment I use either the filter() operator, or the siblings() operator. I recently ran into an issue with no siblings existsing which caused my chain to stop, but as I'm a relative newbie it would be good to know if there are any preferred way, pro's and con's etc.
These are the methods I use to set selected tabs, or use in similar scenarios:
$('#myId')
.addClass('selected')
.siblings()
.removeClass('selected');
$('.tabs > li')
.removeClass('selected')
.filter('#myID')
.addClass('selected');
Any advice appreciated.