Magp.ie

A nest for the random, shiny, online tidbits I stumble across…

Main menu

Skip to primary content
Skip to secondary content
  • Home
  • About me…

Tag Archives: exists

How to check if an element exists in jQuery

Posted on August 3, 2011 by Eoin
2

if ( $("#mydiv").length ){
  // do something here
}

Briefer again…

if ( $("#mydiv")[0] ){
  // do something here
}

via http://aaronrussell.co.uk/legacy/check-if-an-element-exists-using-jquery/

53.734750 -8.989992
Posted in Code | Tagged exists, jQuery, selector | 2 Replies

Join 181 other followers

Categories

  • Code
  • Guides
  • Shortcuts

Top Rated

Poll

Content

aliases array bash character set cheat sheet coda commands cross-browser CSV encoding ExternalInterface Flash format format xml javascript jQuery LSO Mac OSX Microsoft SQL Server MySQL parse assignment value php plugin polldaddy polls Port forwarding PuTTY ratings regex regular expression screen Service Broker shortcuts SSH SVN terminal textwrangler tips UNIX Script UTF8 validate email validate url wordpress xkcd XML
Support Wikipedia
Theme: Customized Twenty Eleven | Blog at WordPress.com.
Follow

Get every new post delivered to your Inbox.

Join 181 other followers

Powered by WordPress.com