0

I am unsure which elements are being targeted within my .on

 $('.levelFour').on('mouseover','> li',function(m){

I wonder, is there a way to display which elements are being targeted?

Jamie Hutber
  • 26,790
  • 46
  • 179
  • 291

3 Answers3

0

Inside an event handler, this will be bound to the element that the event fired on. To create a jQuery object from it, use $(this).

jonvuri
  • 5,738
  • 3
  • 24
  • 32
0

You can run the following command in your browser console

$('.levelFour > li')

It will list all the elements which are targeted by the event handler at the point of execution. It will vary time to time depends on your dom structure.

Arun P Johny
  • 384,651
  • 66
  • 527
  • 531
  • As i suspected... Not quite what i was hoping for though. I must say its odd. As i know it will look for the selector within `.levelFour` But how can `>` operator work without a parent to do the test against. I wonder how this is computed or worked out. – Jamie Hutber Mar 12 '13 at 13:34
  • since your base is ` $('.levelFour')` it will look for children of `.levelFour` – Arun P Johny Mar 12 '13 at 13:41
  • i only want first decenents of .levelFour, hence `>`. So what you're saying is I can do `'> li'` as i have done and it will target the first set of children? – Jamie Hutber Mar 12 '13 at 13:43
  • If you look at http://jsfiddle.net/MW6Cq/ you can find that the border is applied only to the direct children – Arun P Johny Mar 12 '13 at 15:00
0

Try this

$('.levelFour').on('mouseover','> li',function(m){
//something
}).css("border","1px solid red");

will change the border of element to red. hope it helps.

Nikhar
  • 1,074
  • 8
  • 23