Simplify code

Simplify code

Hi everyone,

I am wondering whether I can simplify my code any further. I am creating a plugin where you call it as so:

$('#csTriggers, #csTargets').switchContent();

In the plugin, I have the following code:

var triggerContainer;
var targetContainer;

this.each(function() {
if ($(this).attr('id') == 'csTargets') {
targetContainer = $(this);
}
else if ($(this).attr('id') == 'csTriggers') {
triggerContainer = $(this);
}

});

I have to do this rather than var targetContainer= this[0]. If I change the order of the triggers and targets, then var targetContainer would equal this[1] rather than this[0].

Now the code above works but I am wondering if there is a simpler wayof coding using some jQuery functions, I have researched and not found anything but wanted to check just in case.

Many thanks in advance for you help.

Phil