$
From FirebugWiki
(Difference between revisions)
Sebastianz (Talk | contribs) m |
($ is not a shortcut for getElementById anymore (description changed)) |
||
| (One intermediate revision not shown) | |||
| Line 1: | Line 1: | ||
| - | This command returns a single HTML or XML element with the given id. This means it is actually a shortcut for <code>[https://developer.mozilla.org/en/DOM/document. | + | This command returns a single HTML or XML element with the given id. This means it is actually a shortcut for <code>[https://developer.mozilla.org/en/DOM/document.querySelector document.querySelector()]</code>. |
If the JavaScript on the page already defines <code>$</code> for something else (like e.g. jQuery does), it will not be overwritten by this command. | If the JavaScript on the page already defines <code>$</code> for something else (like e.g. jQuery does), it will not be overwritten by this command. | ||
| 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> | ||
Latest revision as of 19:07, 25 January 2013
This command returns a single HTML or XML element with the given id. This means it is actually a shortcut for document.querySelector().
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 |
[edit] Syntax
$(selector)
[edit] Parameters
[edit] selector
Selector used to match the element to return. This follows the syntax of document.querySelector(). (required)
[edit] Examples
$("#element")
This returns the element with the id element.