What is the point of this?  Why not just always set nextElem.val(window.location.href) ?  Could use a comment.