Mah*_*aha 2 javascript jquery developer-tools
我在一些开发人员工具中有一个调试JS和jQuery脚本的习惯.我意识到Chrome开发工具将x.fn.x.init显示为$()和$(this)的值.但是我没有意识到这些价值是什么:
码
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<script src="jquery-2.0.2.min.js" ></script>
<script src="jquery.ui.widget.js" ></script>
<title></title>
<script type="text/javascript">
$(document).ready(function () {
var outstring = "";
outstring = "" + $() + $(this);
});
</script>
</head>
<body>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

这实际上是实例化背后的真实代码 $
jQuery.fn = jQuery.prototype = {
// The current version of jQuery being used
jquery: core_version,
constructor: jQuery,
init: function( selector, context, rootjQuery ) {
var match, elem;
.....
Run Code Online (Sandbox Code Playgroud)
然后在第263行
// Give the init function the jQuery prototype for later instantiation
jQuery.fn.init.prototype = jQuery.fn;
Run Code Online (Sandbox Code Playgroud)
由于您使用的是缩小版本,因此可以转换为您所看到的内容.
| 归档时间: |
|
| 查看次数: |
2456 次 |
| 最近记录: |