Javascript对象,表现方式一:
1 person = new Object();2 person.firstname = "An";3 person.lastname = "na";4 person.age = 12;5 alert(person.age);View Code
Javascript对象,表现方式二:
1 function person(firstname, lastname, age) {2 this.firstname = firstname;3 this.lastname = lastname;4 this.age = age;5 }6 var newPerson = new person("An", "na", 12);7 alert(newPerson.firstname)View Code
Javascript对象,表现方式三:
1 var person = { firstname: "An", lastname: "na", age: 12 };2 alert(person.firstname);View Code
Jquery扩展简单,简单应用如下:
1 <!DOCTYPE html> 2 3 <html lang="en" xmlns="http://www.w3.org/1999/xhtml"> 4 <head> 5 <meta charset="utf-8" /> 6 <title></title> 7 <script type="text/javascript" src="jquery-1.7.1.min.js"></script> 8 <script type="text/javascript"> 9 //jquery 扩展:10 jQuery.extend({11 my: function () {12 alert("初试jquery扩展");13 }14 })(jQuery);15 //使用:16 $.my();17 18 //jquery对象扩展:19 jQuery.fn.extend({20 self: function () {21 alert("jquery对象扩展");22 }23 })24 //使用:25 $("span").self();//需要用对象.26 </script>27 </head>28 <body>29 <span>jquery对象扩展</span>30 </body>31 </html>View Code
...以上为个人学习所写,可能不完整,欢迎补充...
新闻热点
疑难解答