SigmundL (1) [Avatar] Offline
#1
And not $('#example')? In another example var text = $('#theList').text(); was used, but not in this case, why?
Jan Voges (2) [Avatar] Offline
#2
Re: Listing 4.1 - why $('#example')[0]?
Hi,

the code line:
$('#example')[0].onmouseover = function(event) { ... }

$('#example') is a wrapped set and $('#example')[0] (or $('#example').get(0)) is a DOM element. And onmouseover is only a DOM element attribute and has no idea of jQuery's concept of wrapped sets. Or in other words jQuery's wrapped set has no attribute named "onmouseover".

hth
Jan
bear.bibeault (675) [Avatar] Offline
#3
Re: Listing 4.1 - why $('#example')[0]?
Exactly. Remember, this example is showing the concepts of using DOM level 0. It's not the way you'd actually do it in a real page -- which is, of course, shown later in the chapter.