linerrack.blogg.se

Javascript chrome console calculator
Javascript chrome console calculator





javascript chrome console calculator

This function also supports a second parameter, startNode, that specifies an 'element' or Node from which to search for elements. The following example returns a reference to the currently selected element and displays its src property: Right-click on the returned result and select Reveal in Elements Panel to find it in the DOM, or Scroll in to View to show it on the page.

javascript chrome console calculator

The following example returns a reference to the first element in the document:

javascript chrome console calculator

When called with one argument, this function is a shortcut for the document.querySelector() function. $(selector) returns the reference to the first DOM element with the specified CSS selector. The $0 now refers to newly selected element, while $1 returns the previously selected one: # $(selector ) The image below shows a different element selected in the same page. In the Console drawer, $0 has been evaluated and displays the same element: In the following example, an img element is selected in the Elements panel. $0 returns the most recently selected element or JavaScript object, $1 returns the second most recently selected one, and so on. The $0, $1, $2, $3 and $4 commands work as a historical reference to the last five DOM elements inspected within the Elements panel or the last five JavaScript heap objects selected in the Profiles panel. Evaluating $_.length to find the length of the array, the value stored in $_ changes to become the latest evaluated expression, 4: # $0 - $4 In the next example, the evaluated expression initially contains an array of names. The $_ property is then evaluated, which contains the same value: In the following example, a simple expression ( 2 + 2) is evaluated. $_ returns the value of the most recently evaluated expression. Looking for console.log(), console.error(), and the rest of the console.* functions? See Console API Reference. They won't work if you try to call them in your scripts. These functions only work when you call them from the Chrome DevTools Console.







Javascript chrome console calculator