No need to use the ternary operator, .toggleClass()takes a second argument to determine whether to add or remove a class:
$j('#next').toggleClass('filter', ((pos - maxPos) == c.clientWidth))
However, to answer your question as you asked (do not use it!):
$j('#next')[((pos - maxPos) == c.clientWidth) ? 'addClass' : 'removeClass']('filter');
source
share