<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
var animal = {
type: "mammal"
};
var dog = {
sound: "bark"
};
dog.extends(animal);
alert(dog.type);
});
</script>
上面的代码没有警告,并且错误地说undefined不是函数。知道为什么吗?
答案 0 :(得分:3)
试试这个
$(document).ready(function(){
var animal = {
type: "mammal"
};
var dog = {
sound: "bark"
};
$.extend(dog, animal);
alert(dog.type);
});