Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

5
  • This was my first fought :). Unfortunately, in many cases i need to click/show/hide and do something else. For example, in my code sample - return from method. Or write something to log. Or whatever. Commented Apr 5, 2013 at 16:13
  • It's not clear what you want but you can use this in most cases if you use each. Commented Apr 5, 2013 at 16:13
  • @Kevin Sorry, i can't understand. If i add it to next line after "click" - it will execute if element is visible and if it's not visible. And it's common to do logic like "if something is visible - hide and return. Than check if something else if not visible, if so - show and return. Finally, check some element has text. If so, clear and return." Commented Apr 5, 2013 at 16:16
  • Yes, something like temporary variable. Does jQuery provides some shortcut to it like "last-match"? Commented Apr 5, 2013 at 16:19
  • No, that wouldn't really make sense. If you need to use a value more than once, declare a variable. See the various solutions in my answer. Commented Apr 5, 2013 at 16:21