Skip to content

Daily Archives: February 10, 2013

You are here:
  1. Home
  2. 2013
  3. February
  4. 10

How to check if array contains specific element?

JavaScript && jQueryBy kavecanFebruary 10, 2013

You can use jQuery’s inArray function. Ie, to check if array myArray contains number 10 in it, you can use next code: if ($.inArray( myArray, 10) !== -1) { alert(“Yes, array myArray contains number 10 as one of it’s elements!”); } else { alert(“Nope, array myArray doesn’t contains number 10!”); }

© 2026. Kavecan.com. All rights reserved.
Go to Top