jquery扩展与插件
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<p>111</p>
<p>222</p>
<p>333</p>
<script src="jquery-3.3.1.min.js"></script>
<script>
// 静态方法
$.extend({
MyPrint:function () {
console.log(123)
}
});
$.MyPrint();
// 给jQuery是实例添加方法
$.fn.extend({
GetText:function () {
console.log($(this).html())
}
});
$('p').GetText();
</script>
</body>
</html>