36 lines
966 B
HTML
36 lines
966 B
HTML
<!DOCTYPE html>
|
|
<html>
|
|
|
|
<head>
|
|
<title>jquery链式原型</title>
|
|
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1">
|
|
<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
|
|
<link href="/jscss/style.css" rel="stylesheet" type="text/css" />
|
|
</head>
|
|
|
|
<body>
|
|
原型方法,链式调用。<br/>
|
|
<a class="btn" onclick="ciydom('ciyon').method1().method2()">链式调用</a>
|
|
</body>
|
|
|
|
<script type="text/javascript">
|
|
'use strict';
|
|
function _ciydom(dom) {
|
|
this._dom = dom;
|
|
console.log('init', dom);
|
|
}
|
|
_ciydom.prototype.method1 = function () {
|
|
console.log('method1', this);
|
|
return this;
|
|
};
|
|
_ciydom.prototype.method2 = function () {
|
|
console.log('method2', this);
|
|
return this;
|
|
};
|
|
function ciydom(dom) {
|
|
return new _ciydom(dom);
|
|
}
|
|
</script>
|
|
|
|
</html> |