As suggested in the comments, consider storing the values that are used for all elements of the CSS class, in this example I will choose .something .
.something { position: absolute; display: inline-block; }
Further, in jQuery you can save a copy of your span element in a variable, as you are going to use it in both cases. In the else block, you can simply apply the class and add individual styles.
EDIT . You can simplify the code even further. You will return the range that will happen, so you only need to check if i 0 does not match.
var array = $('table').find('th').map(function (i){ var span = $('<span>' + $(this).text() + '</span>'); if (i !== 0) { span.addClass('something').css({ width: $(this).outerWidth() + 'px', right: w[i-1] + 'px' }); } return span; }).get();
Sacha source share