[jQuery] Changing a class name without clicking

[jQuery] Changing a class name without clicking


Hi all,
I have the following:
<div class="unselected" >content</div>
I want to change unselected into selected when calling a function.
The ways I'm finding to do a class name change is using a clicking:
$('.unselected').click(function(){
$('.selected').attr('class','unselected');
$(this).attr('class','selected');
});
But I don't want to click, I need to do it by calling a function ..
how can I do that?
Thanks a lot !