<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
</head>
<script src="js/jquery.js"></script>
<body>
<script>
var result = $.extend({add:function(){ return (1+1)}},{'name':111,'age':1100},{del:function(){ alert('Del info!')}});
alert(result.add());
alert(result.name);
result.del();
$.extend({infos:function(){ alert('It is infos.');}});
$.infos(); //合并到jquery的全局对象中
$.fn.extend({myinfos:function(){ alert('It is myinfos');}});
var a = $("#div");
a.myinfos();//合并到jquery的实例对象中
</script>
<div id="div"></div>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
</head>
<script src="js/jquery.js"></script>
<body>
<script>
var result = $.extend({add:function(){ return (1+1)}},{'name':111,'age':1100},{del:function(){ alert('Del info!')}});
alert(result.add());
alert(result.name);
result.del();
$.extend({infos:function(){ alert('It is infos.');}});
$.infos(); //合并到jquery的全局对象中
$.fn.extend({myinfos:function(){ alert('It is myinfos');}});
var a = $("#div");
a.myinfos();//合并到jquery的实例对象中
</script>
<div id="div"></div>
</body>
</html>
本文演示了如何使用jQuery扩展JavaScript功能,并展示了其在HTML文档中的应用,包括添加、获取和删除元素的方法。
712

被折叠的 条评论
为什么被折叠?



