Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

JavaScriptÖ®±£ÁôСÊýµãºóÖ¸¶¨Î»Êý

ÔÚ¿ª·¢¹ý³ÌÖо­³£Óöµ½Òªµ÷ÕûСÊýµÄ¸ñʽ£¬Èç±£ÁôСÊýµãºóÁ½Î»µÈµÈ¡£·½·¨Ò²ÆÄΪ³£¼û£¬±¸ÍüÈçÏ¡£
 µÚÒ»ÖÖ£¬ÀûÓÃmath.round 
   var original=28.453
1) //round "original" to two decimals
var result=Math.round(original*100)/100;  //returns 28.45
2) // round "original" to 1 decimal
var result=Math.round(original*10)/10;  //returns 28.5
µÚ¶þÖÖ£¬js1.5ÒÔÉÏ¿ÉÒÔÀûÓÃtoFixed(x) £¬¿ÉÖ¸¶¨Êý×Ö½ØÈ¡Ð¡Êýµãºó xλ
3) //round "original" to two decimals
var result=original.toFixed(2); //returns 28.45
4) // round "original" to 1 decimal
var result=original.toFixed(1); //returns 28.5
ÒÔÉÏÁ½ÖÖ·½·¨×îͨÓ㬵«È´ÎÞ·¨Âú×ãÄ³Ð©ÌØÊâÒªÇ󣬱ÈÈç±£ÁôСÊýµãºóÁ½Î»£¬Èç¹û²»ÂúÁ½Î»£¬²»ÂúÁ½Î»Ôò²¹Áã¡£´Ëʱ¾ÍÓÐÁ˵ÚÈýÖÖ·½·¨¡£
µÚÈýÖÖ£¬×ª»»º¯Êý£¬Õâ¶Î´úÂëÀ´Ô´ÓÚ¹úÍâÒ»¸öÂÛ̳¡£
function roundNumber(number,decimals) {
var newString;// The new rounded number
decimals = Number(decimals);
if (decimals < 1) {
newString = (Math.round(number)).toString();
} else {
var numString = number.toString();
if (numString.lastIndexOf(".") == -1) {// If there is no decimal point
numString += ".";// give it one at the end
}
var cutoff = numString.lastIndexOf(".") + decimals;// The point at which to truncate the number
var d1 = Number(numString.substring(cutoff,cutoff+1));// The value of the last decimal place that we'll end up with
var d2 = Number(numString.substring(cutoff+1,cutoff+2));// The next decimal, after the last one we want
if (d2 >= 5) {// Do we need to round up at all? If not, the string will just be truncated
if (d1 == 9 && cutoff > 0) {// If the last digit is 9, find a new cutoff point
while (cutoff > 0 && (d1 == 9 || isNaN(d1))) {
if (d1 != ".") {
cutoff -= 1;
d1 = Number(numString.substring(cutoff,cutoff+1));
} else {
cutoff -= 1;
}
}
}
d1 += 1;
}
if (d1 == 10) {
numString = numString.substring(0, numString.lastIndexOf("."));
var roundedNu


Ïà¹ØÎĵµ£º

JavaScriptʵÏÖÍøÒ³µÄ·Å´óËõСÒÔ¼°Í϶¯¹¦ÄÜ

ÏîÄ¿ÖÐÓöµ½Ò»ÖÖÇé¿ö£¬¿ª·¢µÄÒ³Ãæ»æÖƳöÀ´µÄͼƬ»òÕßµ×ͼ¶¼±È½Ï´ó£¬³¬¹ýÆÁÄ»´óСÐí¶à¡£ÎªÁ˸ÄÉÆÊ¹ÓÃÌåÑ飬ÐèÒª¸øÕâÀàÒ³ÃæÌí¼Ó·Å´ó¡¢ËõСÒÔ¼°Æ½ÒƵŦÄÜ¡£¾­¹ýÒ»·¬ËÑË÷ºÍ³¢ÊÔ£¬ÊµÏÖÁËÓйع¦ÄÜ£¬±¸ÍüÈçÏ¡£
JavaScript£º
var zoomRate = 20;//ÿ´Î·ÅËõ±ÈÀýÔöÁ¿
var maxRate = 300;//×î´ó·Å´ó±¶Êý
var minRate = 20;//×îС ......

JavaScript¸ß¼¶³ÌÐòÉè¼ÆÑ§Ï°±Ê¼Ç2£º Ä£Ä⺯ÊýÖØÔØ

ÓÃarguments¶ÔÏó¼ì²â´«µÝ¸øº¯ÊýµÄ²ÎÊý¸öÊý£ºarguments.length
function test(){
    if(arguments.length == 1)
        alert(arguments[0] + "£¬ÄãºÃ");
    else if(arguments.length == 2)
        alert(a ......

JavaScriptµÄÈýÖÖ¶Ô»°¿ò

1£ºÖ»ÊÇÌáÐÑ£¬²»ÄܶԽű¾²úÉúÈκθı䣻
2£ºÒ»°ãÓÃÓÚÈ·ÈÏ£¬·µ»Ø true »òÕß false £¬ËùÒÔ¿ÉÒÔÇáËÉÓÃÓÚ if...else...ÅжÏ
3£º Ò»¸ö´øÊäÈëµÄ¶Ô»°¿ò£¬¿ÉÒÔ·µ»ØÓû§ÌîÈëµÄ×Ö·û´®£¬³£¼ûÓÚijЩÁôÑÔ±¾»òÕßÂÛ̳ÊäÈëÄÚÈÝÄÇÀïµÄ ²åÈëUBB¸ñʽͼƬ
<mce:script language="javascript"><!--
function ale()
{//Õâ¸ö»ù±¾Ã»Ó ......

²Î¼ÓJavaScriptÃæÊÔ£¬±ØÐë¸ã¶®µÄÎÊÌâ

²Î¼ÓJavaScriptÃæÊÔ£¬±ØÐë¸ã¶®µÄÎÊÌâ£¨ÍÆ¼ö£©
Ò». JavaScriptÖеĶÔÏó.
JavaScriptÖеÄObjectÊÇÒ»×éÊý¾ÝµÄkey-valueµÄ¼¯ºÏ, ÓеãÀàËÆÓÚJavaÖеÄHashMap, ËùÓÐÕâЩÊý¾Ý¶¼ÊÇObjectÀïµÄproperty.
ͨ³£Çé¿öÏÂ, JavaScriptÖн¨Á¢Ò»¸ö¶ÔÏóÓÃ"new"¼ÓÉÏconstructor functionÀ´ÊµÏÖ.
Èçnew Date(), new Object()µÈ.
var bo ......

javascriptÓëasp.netʵÏÖÎļþÉÏ´«

·½·¨Ò»£ºÊ¹ÓÃFileUpLoad ¿Ø¼þ¶à¸öÖ±½ÓÉÏ´«¡£ÕâÑù×öµÄÎÊÌâ¾ÍÊÇÒªÇóÒ³ÃæÌá½»£¬´Ó¶øµ¼ÖÂһЩ²»Ó¦¸ÃˢеÄÄÚÈÝÔڴ˲Ù×÷¹ý³ÌÖÐÏûʧµô¡£µ«ÊÇÓÃScriptManger À´Åª È´ÓÖ²»ÄÜÉÏ´«ÁË Ô­ÒòºÜ¼òµ¥ FileUpLoad ¿Ø¼þÒªÇópost¡£ÓÉÓÚÕâ¸öÎÊÌâ ËùÒÔ¶àÊýÈ˶¼ºÜÉÙ²ÉÓÃÕâÖÖ·½·¨£¬²»µÃ²»ÁíѰËü·¨¡£ÏÂÃæµÄ·½·¨¶þ½â¾ö´ËÎÊÌâ¡£
·½·¨¶þ£ºÊ¹ÓÃHtml±êÇ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ