$
From FirebugWiki
(Difference between revisions)
Sebastianz (Talk | contribs) (Added description of syntax and linked back to Command Line API) |
|||
| (One intermediate revision not shown) | |||
| Line 5: | Line 5: | ||
== Syntax == | == Syntax == | ||
<source lang="javascript"> | <source lang="javascript"> | ||
| - | $( | + | $(selector) |
</source> | </source> | ||
== Parameters == | == Parameters == | ||
| - | === | + | === selector === |
| - | + | Selector used to match the element to return. This follows the syntax of <code>document.querySelector()</code>. '''(required)''' | |
== Examples == | == Examples == | ||
<source lang="javascript"> | <source lang="javascript"> | ||
| - | $("element") | + | $("#element") |
</source> | </source> | ||
| Line 20: | Line 20: | ||
== See also == | == See also == | ||
| - | [[Command Line API]] | + | * [[Command Line API]] |
Revision as of 15:13, 10 December 2012
This command returns a single HTML or XML element with the given id. This means it is actually a shortcut for document.getElementById().
If the JavaScript on the page already defines $ for something else (like e.g. jQuery does), it will not be overwritten by this command.
Contents |
Syntax
$(selector)
Parameters
selector
Selector used to match the element to return. This follows the syntax of document.querySelector(). (required)
Examples
$("#element")
This returns the element with the id element.