I'm trying to keep the code as clean as possible. Is this the best approach? I don't use jQuery that often.
// ==============================================
// Trigger longer description on product page
// ==============================================
var longDescription = $j("#js-long-description");
var shortDescription = $j("#js-shortened-description");
var showHide = $j("#js-trigger-long-description");
var inSpeed = 500;
var outSpeed = 100;
longDescription.hide();
showHide.on("click", function () {
var buttonTxt = longDescription.is(':visible') ? 'Read More' : 'Read Less';
showHide.text(buttonTxt);
if (longDescription.is(':visible')) {
shortDescription.fadeIn(inSpeed);
longDescription.fadeOut(outSpeed);
} else {
shortDescription.fadeOut(outSpeed);
longDescription.fadeIn(inSpeed);
}
});