You have to declare your classChanger on the jQuery prototype:
$.fn.classChanger = function(path, changeClass, duration) {
$(path).removeClass(changeClass);
return this.addClass(changeClass);
};
For more info, read the jQuery Plugin Authoring Guide.
Update: As pointed out in the comments, if you intend for path and the selector to always be identical, you should forgo path completely, and just use this throughout.
Since you haven't specified exactly what it is you're trying to do, I'm assuming you want to remove the class, then wait for the duration specified and then re-add the class. If that's the case, here's some sample code:
$.fn.classChanger = function(changeClass, duration) {
var $this = this;
setTimeout(function() {
$this.addClass(changeClass);
}, duration);
return this.removeClass(changeClass);
};
$('.flightDetails .option').classChanger('selected', 300);
Here's the fiddle: http://jsfiddle.net/ur7SN/