4 ms·
Paste this snippet into your dev console, then mouseover the colours to get a preview. Array.prototype.forEach.call($$("td[bgcolor]"), function(td) { t
by dmnd 13y ago
Paste this snippet into your dev console, then mouseover the colours to get a preview.
Array.prototype.forEach.call($$("td[bgcolor]"), function(td) {
td.parentNode.addEventListener('mouseenter', function() {
$("td[bgcolor]").setAttribute("bgcolor", td.parentNode.children[1].getAttribute("bgcolor"));
});
});
- hamxiaoz 13y agoWhat does the $$ mean?
- thedufer 13y agoLooking at it in the console, it looks like $ returns a single DOM element and $$ returns a NodeList (array-like object) of DOM elements. Not sure what library that is.
- scrabble 13y agoPrototypeJS works that way.
- reubenmorais 13y agoNo library, at least in Firefox it's defined by devtools and only works in the console (provided the page doesn't have it's own $ and $$ globals). [0] http://dxr.mozilla.org/mozilla-central/source/toolkit/devtools/server/actors/webconsole.js#1016 http://dxr.mozilla.org/mozilla-central/source/toolkit/devtoo... [1] http://dxr.mozilla.org/mozilla-central/source/toolkit/devtools/webconsole/utils.js#1407 http://dxr.mozilla.org/mozilla-central/source/toolkit/devtoo... Edit: It works in the WebKit devtools too: [0] https://mxr.mozilla.org/chromium/source/src/third_party/WebKit/Source/core/inspector/InjectedScriptSource.js#1315 https://mxr.mozilla.org/chromium/source/src/third_party/WebK...
- dmnd 13y agoIt's shorthand for document.querySelectorAll: https://developers.google.com/chrome-developer-tools/docs/commandline-api#selector_1 https://developers.google.com/chrome-developer-tools/docs/co...