Difference between revisions of "$"

From FirebugWiki
Jump to: navigation, search
m (Added categories)
 
(One intermediate revision by one other user 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.getElementById document.getElementById()]</code>.
+
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 21: Line 21:
 
== See also ==
 
== See also ==
 
* [[Command Line API]]
 
* [[Command Line API]]
 +
 +
[[Category:Firebug]]
 +
[[Category:UI]]
 +
[[Category:API]]

Latest revision as of 16:01, 21 November 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.

Syntax[edit]

$(selector)

Parameters[edit]

selector[edit]

Selector used to match the element to return. This follows the syntax of document.querySelector(). (required)

Examples[edit]

$("#element")

This returns the element with the id element.

See also[edit]