1.) What's the difference between these two queries, exactly?
$( "#orderedlist li" )
$( "#orderedlist>li" )
2.) In the jQuery file itself there is a function that returns the following:
function now(){
return +new Date;
}
What does that mean? I've never seen +new before.
3.) In a brief skimming of a tutorial, I observed the following samples:
// use this to reset a single form
$( "#reset" ).click( function()
{
$( "form" )[0].reset();
});
// use this to reset several forms at once
$( "#reset" ).click( function()
{
$( "form" ).each( function()
{
this.reset();
});
});
When I try to reference my own queries by array indexes, they don't seem to work. Yet this example clearly did when I tested it. What could I be doing wrong?
Edit: I'll put this one into its own question soon. Edit 2: Actually I may be able to debug it myself. Hang on...
I have guesses to each of these, but short of dissecting the jQuery file itself in full, I'm not completely certain what's at work here. Help appreciated.
Question #1:
#orderedlist li
is a "descendant selector": an li
anywhere within an #orderedlist
.#orderedlist>li
is a "child selector": an li
which is a direct child of an #orderedlist
.Question #2:
That's using the unary plus operator - it's equivalent to:
return Number(new Date);
see: http://xkr.us/articles/javascript/unary-add/ - it gives the number of milliseconds since the UNIX epoch.
Question #3:
I don't know about this one. Could you post a minimal failing example?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With