Cannot get Array.indexOf method to work in Javascript
<p>I have a fairly large program that I have simplified to show the problem that I am having. I have 2 div's under which I have an image and some text. When I hover on the image, the jQuery hover over image event fires. Through all this, I am able to get the Id's of both the images &amp; their parent div's. However, when I try to get the index value of the Id's in an array, it always returns -1 ie... not found.</p>

<p>Can you please help. The code is enclosed below. I am new to javascript &amp; jQuery and hence the need of some help. Maybe the solution is very trivial.</p>

<p>Thanks in advance. Regards, sbguy</p>

<pre><code>&lt;html&gt;
&lt;head&gt;
&lt;script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"&gt;&lt;/script&gt;
&lt;script type="text/javascript"&gt;
var input_array = new Array("input1_Id", "input2_Id");
var div_array = new Array("div1_Id", "div2_Id");

window.onload=function(){
    jQuery.ready();
    img_hover_event_handler();
}
//________________________________________________  

function img_hover_event_handler() {
    var input_id = "";
    var div_id = "";
    var input_index, div_index;
    $("input.Lrollover").hover(
        function() {    
            input_id = new String(this.id);
            input_index = new String(input_array.indexOf(div_id));
            div_id = new String($(this).closest('div').attr('id')); // id of the parent div
            div_index = new String(div_array.indexOf(div_id));
            alert(input_id + ", " + input_index + ", " + div_id + ", " + div_index);            
        }, 
        function() {
   });  
}

&lt;/script&gt;
&lt;/head&gt;

&lt;body&gt;
  &lt;div id="div1_Id"&gt;
    &lt;input class="Lrollover" id="input1_Id" type="image" src="images/LGbtn_off.png" alt="Image1" /&gt;
    &lt;p id="myp1_Id"&gt;"Hello World 1"&lt;/p&gt;
  &lt;/div&gt;
  &lt;br&gt;&lt;br&gt;&lt;br&gt;
  &lt;div id="div2_Id"&gt;
  &lt;input class="Lrollover" id="input2_Id" type="image" src="images/LGbtn_off.png" alt="Image2"/&gt;
    &lt;p id="myp2_Id"&gt;Hello World 2"&lt;/p&gt;
  &lt;/div&gt;

 &lt;/body&gt; 
&lt;/html&gt;
</code></pre>
