I have the following javascript code:
function changeButtonState(targetSelector, action, iconClass) {
var $target = $(targetSelector);
var $targetSpan = $(targetSelector + ' span');
$targetSpan.removeClass('sprite-blank').addClass(iconClass);
}
How can I make it so that the $targetSpan.removeClass(..).addClass
only work if the iconClass
has a value when the function is called. I guess what I am confused about is do I check if it is defined or do I check if it has a length of 0 or more?