It's not a jQuery feature but a feature for debugging purposes.
(它不是jQuery功能,而是用于调试的功能。)
You can for instance log something to the console when something happens. (例如,您可以在发生某些情况时将某些内容记录到控制台。)
For instance: (例如:)
$('#someButton').click(function() {
console.log('#someButton was clicked');
// do something
});
You'd then see #someButton was clicked
in Firebug's “Console” tab (or another tool's console — eg Chrome's Web Inspector) when you would click the button.
(然后,您会#someButton was clicked
Firebug的“控制台”选项卡(或其他工具的控制台,例如Chrome的Web Inspector)中看到#someButton was clicked
了#someButton was clicked
。)
For some reasons, the console object could be unavailable.
(由于某些原因,控制台对象可能不可用。)
Then you could check if it is - this is useful as you don't have to remove your debugging code when you deploy to production: (然后,您可以检查它是否有用-这很有用,因为在部署到生产环境时不必删除调试代码:)
if (window.console && window.console.log) {
// console is available
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…