2

I have a snippet of code that is able to retrieve the div, but I am also after the class

 $(document).ready(function() {
            document.onmouseover = function(e) {
                var divID = e.target.id;
            }
        });

This works great, but I also need to get the div class, I was hoping to do something like var divClass = e.target.class but no dice.

Ian
  • 50,146
  • 13
  • 101
  • 111
Bwyss
  • 1,736
  • 3
  • 25
  • 48
  • You might want to have a look at http://stackoverflow.com/questions/4069982/document-getelementbyid-vs-jquery – Juto Aug 09 '13 at 14:11

1 Answers1

11

Try using the following:

e.target.className
Mathew Thompson
  • 55,877
  • 15
  • 127
  • 148
  • Why do you need to use `document.getElementById`? You already have a reference to the element with `e.target`. `e.target.className` should be plenty fine – Ian Aug 09 '13 at 14:14