Find out index of any element in Array using JQuery

Virendradugar
Posted by Virendradugar under jQuery category on | Views : 18732
Below code will find index of element in the Array using JQuery. You can download the Jquery from http://docs.jquery.com/Downloading_jQuery .

<script type="text/javascript" src="Script/jquery-1.3.2.js"></script>

<script type="text/javascript">
$(document).ready(function(){
var arr = [ "V", "I", "R", "E","N" ];
alert(jQuery.inArray("R", arr));
});
</script>


This will alert(2) as output.

inArray is a in-built function to check array element index.

Click below link to get mostly asked jQuery interview question.
http://jquerybyexample.blogspot.com/2011/08/mostly-asked-jquery-interview-questions.html

Comments or Responses

Login to post response