¡¶Îò͸javascript¡·Ñ§Ï°±Ê¼Ç£ºÈý¡¢ËÆÀàÈ´²»ÊÇÀà
ÒýÑÔ
JavaScriptûÓÐ “Àà”µÄ¸ÅÄÕâÈúܶàѧϰ¹ý¸ß¼¶ÓïÑÔµÄÈ˸е½ºÜ²»Ë¬£¬Æäʵ±ÈÖ®ÓÚCÓïÑÔÓÖÈçºÎÄØ£¿ÏÔÈ»JavaScriptÒª±ÈCÓïÑÔºÃÓúܶࡣ
²»·Ï»°£¬ÉÏ´úÂë
<script language="javascript">
/*Ò»¾ä¾äµÄ¿´¸üÈÝÒ×Ã÷°×*/
//ÉùÃ÷Ò»¸ö¶ÔÏ󣬵«Ëüʲô¶¼Ã»ÓÐ
var life = {};
//ÈκÎʱºò¿ÉÒÔËæÒâµØ¸Ä±ä¶ÔÏóµÄÊôÐÔ»òº¯Êý£¬lifeºóÖ±½Ó½Ó.age£¬Ëü¾ÍÓÐÁËageÊôÐÔ
for(life.age = 1; life.age <= 3; life.age++)
{
switch(life.age)
{
case 1: life.body = "ÂÑϸ°û"; //ageΪ1ʱ£¬ÐÂÔöÒ»¸öbodyÊôÐÔ²¢¸³Öµ
life.say = function(){alert(this.age+this.body)}; //ÐÂÔösay·½·¨
break;
case 2: life.tail = "β°Í"; //ÐÂÔötailÊôÐÔ
life.gill = "Èù"; //ÐÂÔögillÊôÐÔ
life.body = "òòò½"; //ÐÞ¸ÄbodyÊôÐÔµÄÖµ£¬ÒòΪbodyÔÚÉÏÃæÒѾÐÂÔöÁË£¬ËùÒÔÕâÀïÊÇÐÞ¸Ä
life.say = function(){alert(this.age+this.body+"-"+this.tail+","+this.gill)}; //ÐÞ¸Äsay·½·¨
break;
case 3: delete life.tail; //ɾ³ýtailÊôÐÔ
delete life.gill;
Ïà¹ØÎĵµ£º
ÔÚJavascriptÖÐûÓÐclassÀ࣬µ«ÊÇͬÑùÒ²¿ÉÒÔ½øÐжÔÏóµÄ´´½¨¡£ÔÚÃæÏò¶ÔÏóµÄÓïÑÔÖÐÐèҪʵÀý»¯Ä³¸ö¾ßÌåÀàµÄʵÀý£¬ÔÚJavascriptÖÐÔò²»Óá£
ÔÚJavascriptÀ¶ÔÏñ¿ÉÒÔ´´½¨ÐµĶÔÏó£¬Ò²¿ÉÒԼ̳Ð×ÔÆäËû¶ÔÏó¡£Õâ¸ö¸ÅÄî³ÆΪÔÐÍ»¯¼Ì³Ð(prototypal inheritance)¡£
Èκκ¯ÊýÔÚJavascript Öж¼¿ÉÒÔ±»ÊµÀý»¯Ò»¸ö¶ÔÏó¡£
³ÌÐòÈçÏ£º
// ......
ʵÏÖ¿¨Ò³Ê½webµÄjs£º
function ShowContent(id,num){
for(i=1;i<=num;i++){
document.getElementById("page_"+i).className="";
document.getElementById("content_"+i).style.display="none";
}
document.getElementById("content_"+id).style.display="block";
......
¿ª·¢Ê±£¬ÐèÒªÓõ½µÄJavaScript½ø¶ÈÌõ~~~
<style type="text/css">
#out {
width:200px;
height:16px !important;
border:1px solid #5858D1;
text-align:center;
position:relative;
font-size:12px;
_height:18px;
}
#out, #out * {
padding:0;
margin:0;
}
#num {
height:16px;
line-h ......
ÒýÑÔ
ÒªÀí½â JavaScript£¬ÄãµÃÊ×ÏÈ·Å϶ÔÏóºÍÀàµÄ¸ÅÄ»Øµ½Êý¾ÝºÍ´úÂëµÄ±¾Ô¡£Ç°Ãæ˵¹ý£¬±à³ÌÊÀ½çÖ»ÓÐÊý¾ÝºÍ´úÂëÁ½ÖÖ»ù±¾ÔªËØ£¬¶øÕâÁ½ÖÖÔªËØÓÖÓÐמÀ²ø²»ÇåµÄ¹Øϵ¡£JavaScript¾ÍÊÇ°ÑÊý¾ÝºÍ´úÂ붼¼ò»¯µ½×îÔʼµÄ³Ì¶È¡£
»ù±¾ÀàÐÍ
Ò»¡¢¼òµ¥Êý¾ÝÀàÐÍ£ºundefined¡¢null¡¢boolean¡¢number¡¢string£¨×¢Ò⣺¶¼Ê ......