<html>
<head>
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
<meta charset="utf-8">
</head>
<body>
<div id="demo" style="width:100px;height:100px;background-color:black;"></div>
<script type="text/javascript">
$(document).ready(function(){
var obj = $.extend({},{"name":"axe","age":"11"},{"name":"axe","age":"22"});
var obj1 = $.extend({},{"name":"axe","age":"11"},{"name":"axe","age":"22","sex":"boy"},{"name":"loa","age":"32","sex":"girl"});
var obj2 = $.extend(true,{},{"name":"axe","age":"11","family":{"sister":"lina","brother":"sf"}},{"name":"axe","age":"22","family":{"father":"tk","brother":"es"}});
var obj3 = $.extend(false,{},{"name":"axe","age":"11","family":{"sister":"lina","brother":"sf"}},{"name":"axe","age":"22","family":{"father":"tk","brother":"es"}});
console.log(obj);
console.log(obj1);
console.log(obj2);
console.log(obj3);
$.extend({
hi:function(){
console.log("hi!")
}
});
$.hi();
$.fn.extend({
hello:function(){
$(this).mouseover(function(){
console.log("hello");
});
}
});
$("#demo").hello();//必须先定义再使用,不会提升
});
</script>
</body>
</html>
$.extend() and $.fn.extend()
最新推荐文章于 2021-10-07 17:57:36 发布