www.webdeveloper.com
Results 1 to 4 of 4

Thread: Get the index of an element contained into an array, according to the event object

Threaded View

  1. #1
    Join Date
    Jan 2013
    Posts
    84

    Get the index of an element contained into an array, according to the event object

    Hi, ive this code

    html:
    HTML Code:
    <div class="contStella" id="stellaquattro"><img class="stellaVota" src="immagini_sito/stella.png"/></div>
    Javascript + Jquery

    PHP Code:

    var stelleArray=new Array ( $('#stellauno'), $('#stelladue'), $('#stellatre'), $('#stellaquattro'), $('#stellacinque') )

    $(
    '#stellaquattro').mouseover(illuminastelle)
       
    function 
    illuminastelle(event
    {
       
    alert(stelleArray.indexOf(event.target)) // <-this retrive me "-1" that means that the element hasn't been found in the array

    what's the solution? The event.target is "stellaquattro" right? and for what reason i can't found it into the array?
    I tryied event.currenttarget too, without success
    Last edited by American horizo; 07-04-2013 at 12:02 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles