Skip to the content

Fourth Woods Blog


Determine if a value is an option in a select element with jQuery

Author: David Rager
Date: November 9, 2012

To determine if an html select box contains a given value as an option, in jQuery you can try to select the option and see if it exists:

if($("#id option[value='someval']").length != 0) {
  // it exists!
}

That’s it! Have fun!

« Disable the Fn + Function Key combo to the use the function keys on HP laptops
OpenGL Globe Screensaver (Update) »


    Recent Posts

    • Palindraw
    • Android Development – Sudoku Forever
    • 'eregi' is deprecated errors
    • ‘eregi’ is deprecated errors
    • Sudoku Forever

    Recent Comments

      Archives

      • June 2020
      • March 2016
      • February 2016
      • May 2014
      • December 2013
      • July 2013
      • June 2013
      • April 2013
      • January 2013
      • December 2012
      • November 2012
      • October 2012
      • September 2012
      • July 2012
      • May 2012
      • April 2012
      • March 2012
      • February 2012
      • December 2011
      • November 2011
      • October 2011
      • September 2011
      • August 2011
      • July 2011
      • June 2011
      • May 2011
      • April 2011
      • March 2011
      • February 2011
      • June 2005

      Categories

      • Algorithms
      • Android
      • C
      • Cpp
      • Culture and Copyright
      • Database
      • Design Patterns
      • DirectX
      • Emulation
      • Graphics
      • JSP
      • Java
      • JavaScript
      • MySQL
      • OpenGL
      • Oracle
      • PHP
      • Perl
      • Programming
      • SQL Server
      • Security
      • Tips and Tricks
      • Uncategorized
      • XML

      Meta

      • Log in
      • Entries feed
      • Comments feed
      • WordPress.org
      © 2023 Fourth Woods Blog. All rights reserved.