JavaScriptÖÐʹÓÃÔÐÍÀ´´´½¨¶ÔÏó
ÔÚ±àд¹¹Ô캯Êýʱ£¬¿ÉÒÔʹÓÃÔÐͶÔÏó£¨Ëü±¾ÉíÊÇËùÓй¹Ô캯ÊýµÄÒ»¸öÊôÐÔ£©µÄÊôÐÔÀ´´´½¨¼Ì³ÐÊôÐԺ͹²Ïí·½·¨¡£ÔÐÍÊôÐԺͷ½·¨½«°´ÒýÓø´ÖƸøÀàÖеÄÿ¸ö¶ÔÏó£¬Òò´ËËüÃǶ¼¾ßÓÐÏàͬµÄÖµ¡£¿ÉÒÔÔÚÒ»¸ö¶ÔÏóÖиü¸ÄÔÐÍÊôÐÔµÄÖµ£¬ÐµÄÖµ½«¸²¸ÇĬÈÏÖµ£¬µ«½öÔÚ¸ÃʵÀýÖÐÓÐЧ¡£ÊôÓÚÕâ¸öÀàµÄÆäËû¶ÔÏó²»Êܴ˸ü¸ÄµÄÓ°Ïì¡£ÏÂÃæ¸ø³öÁËʹÓÃ×Ô¶¨Òå¹¹Ô캯ÊýµÄʾÀý£¬Circle£¨×¢Òâ this ¹Ø¼ü×ÖµÄʹÓã©¡£
Circle.prototype.pi = Math.PI;
function ACirclesArea () {
return this.pi * this.r * this.r; // ¼ÆËãÔ²Ãæ»ýµÄ¹«Ê½Îª ?r2¡£
}
Circle.prototype.area = ACirclesArea; // ¼ÆËãÔ²Ãæ»ýµÄº¯ÊýÏÖÔÚÊÇ Circle Prototype ¶ÔÏóµÄÒ»¸ö·½·¨¡£
var a = ACircle.area(); // ´ËΪÈçºÎÔÚ Circle ¶ÔÏóÉϵ÷ÓÃÃæ»ýº¯Êý¡£
ʹÓÃÕâ¸öÔÔò£¬¿ÉÒÔ¸øÔ¤¶¨ÒåµÄ¹¹Ô캯Êý£¨¶¼¾ßÓÐÔÐͶÔÏ󣩶¨Ò帽¼ÓÊôÐÔ¡£ÀýÈ磬Èç¹ûÏëÒªÄܹ»É¾³ý×Ö·û´®µÄÇ°ºó¿Õ¸ñ£¨Óë VBScript µÄ Trim º¯ÊýÀàËÆ£©£¬¾Í¿ÉÒÔ¸ø String ÔÐͶÔÏó´´½¨×Ô¼ºµÄ·½·¨¡£
// Ôö¼ÓÒ»¸öÃûΪ trim µÄº¯Êý×÷Ϊ
// String ¹¹Ô캯ÊýµÄÔÐͶÔÏóµÄÒ»¸ö·½·¨¡£
String.prototype.trim = function()
{
// ÓÃÕýÔò±í´ïʽ½«Ç°ºó¿Õ¸ñ
// ÓÿÕ×Ö·û´®Ìæ´ú¡£
return this.replace(/(^\s*)|(\s*$)/g, "");
}
// ÓпոñµÄ×Ö·û´®
var s = " leading and trailing spaces ";
// ÏÔʾ " leading and trailing spaces (35)"
window.alert(s + " (" + s.length + ")");
// ɾ³ýÇ°ºó¿Õ¸ñ
s = s.trim();
// ÏÔʾ"leading and trailing spaces (27)"
window.alert(s + " (" + s.length + ")");
Ïà¹ØÎĵµ£º
Document¶ÔÏóÄÚÈݼ¯ºÏ
document Îĵ²¶ÔÏó - JavaScript½Å±¾ÓïÑÔÃèÊö
———————————————————————
×¢:Ò³ÃæÉÏÔªËØnameÊôÐÔºÍJavaScriptÒýÓõÄÃû³Æ±ØÐëÒ»Ö°üÀ¨´óСд
·ñ ......
×î½ü·¢ÏÖDOMDocument¶ÔÏóºÜÖØÒª,»¹ÓÐXMLHTTPÒ²ºÜÖØÒª
×¢Òâ´óСдһ¶¨²»ÄÜŪ´í.
ÊôÐÔ:
1Attributes ´æ´¢½ÚµãµÄÊôÐÔÁбí(Ö»¶Á)
2childNodes ´æ´¢½ÚµãµÄ×Ó½ÚµãÁбí(Ö»¶Á)
3dataType ·µ»Ø´Ë½ÚµãµÄÊý¾ÝÀàÐÍ
4Definition ÒÔDTD»òXMLģʽ¸ø³öµÄ½ÚµãµÄ¶¨Òå(Ö»¶Á)
5Doctype Ö¸¶¨ÎĵµÀàÐͽڵã(Ö»¶Á)
6documentE ......
ÔÎĵØÖ·£º http://www.w3school.com.cn/js/jsref_tofixed.asp
¶¨ÒåºÍÓ÷¨
toFixed() ·½·¨¿É°Ñ Number ËÄÉáÎåÈëΪָ¶¨Ð¡ÊýλÊýµÄÊý×Ö¡£
Óï·¨
NumberObject.toFixed(num)
²ÎÊýÃèÊö
num
±ØÐè¡£¹æ¶¨Ð¡ÊýµÄλÊý£¬ÊÇ 0 ~ 20 Ö®¼äµÄÖµ£¬°üÀ¨ 0 ºÍ 20£¬ÓÐЩʵÏÖ¿ÉÒÔÖ§³Ö¸ü´óµÄÊýÖµ·¶Î§¡£Èç¹ûÊ¡ÂÔÁ˸òÎÊý£¬½«Óà 0 ´úÌ ......