Added in check to allow to, to be object or string for jquery selector.