[javascript] How to write ternary operator condition in jQuery?