Rob,

>Ok I think that may answer the next question.
>Are you saying that an assertion:
>   $(this)[0] == this
>will always be true?

No, what he's saying is the "this" in $(this) is actually a reference to the
DOM element.

So, in the code:

$("#myDiv").click(
        function (){
                // spit out the actual DOM element
                alert(this);
        }
);

>In other words, if I am using ID selectors and want to access a DOM
>property/method should I read the first element or can I just use the
>jQuery:
>   $("#myDiv").selectedIndex;

The above would not work.  Due to jQuery's chaining mechanism, $("#myDiv")
always returns a jQuery object--so you need to use either the get() method
or reference the jQuery object by it's array shortcut to get to the actual
DOM element.

>or should it always be one of:
>   $("#myDiv").get(0).selectedIndex;
>   $("#myDiv")[0].selectedIndex;

You would need to use on of the two methods you listed above to get to the
selectedIndex property.

-Dan


_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/

Reply via email to