<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script src="jq.js" type="text/javascript" charset="utf-8"></script>
</head>
<body>
<script type="text/javascript">
var tors = function(a1,a2){
this.name = '娃娃'
this.age = '1岁'
this.init(a1,a2);
};
tors.prototype = {
init: function(a1,a2){
console.log('我init')
this.render();
this.fangfa(a1,a2);
},
render: function(){
$("body").append('<div id="buttonLink">按钮</div></br><div id="buttonLink1">按||钮</div>')
},
fangfa: function(a1,a2){
$("#buttonLink").on('click',function(){
// console.log('我被点击了');
// console.log(name);
console.log(a1);
})
$("#buttonLink1").on('click',function(){
// console.log('我被点击了');
// console.log(name);
// this.name = '泡泡糖'
console.log(a2);
console.log(name);
bbq.name = '狗狗'
})
}
}
var bbq = new tors('我a1','她a2');
// console.log(bbq)
console.log(bbq.name);
console.log(tors.name);
</script>
</body>
</html>
prototype练习
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
相关阅读更多精彩内容
- 1. indexOf()方法返回调用String对象中第一次出现的指定值的索引,开始在 fromIndex进行搜索...
- https://blog.csdn.net/liangklfang/article/details/4924613...
- splice() 方法通过删除现有元素和/或添加新元素来更改一个数组的内容。splice.png slice() ...
- indexOf() 方法从数组中返回第一个被找到的元素,否则返回 -1; var a=[2,9,9]; a.ind...