How can I make this work? I have an space in the third element of my array " John".
take a look: http://jsfiddle.net/hyHFT/
<style>
div { color:blue; }
span { color:red; }
</style>
<div>"John" found at <span></span></div>
<div>4 found at <span></span></div>
<div>"Karl" not found, so <span></span></div>
<script>var arr = [ 4, " Pete", 8, " John" ];
$("span:eq(0)").text(jQuery.inArray("John", arr));
$("span:eq(1)").text(jQuery.inArray(4, arr));
$("span:eq(2)").text(jQuery.inArray("Karl", arr));
</script>