javascript typeofµÄÓ÷¨
javascript typeofµÄÓ÷¨
¾³£»áÔÚjsÀïÓõ½Êý×é,±ÈÈç ¶à¸öÃû×ÖÏàͬµÄinput, ÈôÊǶ¯Ì¬Éú³ÉµÄ, Ìύʱ¾ÍÐèÒªÅжÏÆäÊÇ·ñÊÇÊý×é.
if(document.mylist.length != "undefined" ) {} Õâ¸öÓ÷¨ÓÐÎó.
ÕýÈ·µÄÊÇ if( typeof(document.mylist.length) != "undefined" ) {}
»ò if( !isNaN(document.mylist.length) ) {}
typeofµÄÔËËãÊý䶨Òå,·µ»ØµÄ¾ÍÊÇ "undefined".
ÔËËãÊýΪÊý×Ö typeof(x) = "number"
×Ö·û´® typeof(x) = "string"
²¼¶ûÖµ typeof(x) = "boolean"
¶ÔÏó,Êý×éºÍnull typeof(x) = "object"
º¯Êý typeof(x) = "function"
typeof ÔËËã·û·µ»ØÒ»¸öÓÃÀ´±íʾ±í´ïʽµÄÊý¾ÝÀàÐ͵Ä×Ö·û´®¡£
¿ÉÄܵÄ×Ö·û´®ÓУº"number"¡¢"string"¡¢"boolean"¡¢"object"¡¢"function" ºÍ "undefined"¡£
È磺
alert(typeof (123));//typeof(123)·µ»Ø"number"
alert(typeof ("123"));//typeof("123")·µ»Ø"string"
typeof ÔËËã·û
·µ»ØÒ»¸öÓÃÀ´±íʾ±í´ïʽµÄÊý¾ÝÀàÐ͵Ä×Ö·û´®¡£
typeof[()expression[]] ;
expression ²ÎÊýÊÇÐèÒª²éÕÒÀàÐÍÐÅÏ¢µÄÈÎÒâ±í´ïʽ¡£
˵Ã÷
typeof ÔËËã·û°ÑÀàÐÍÐÅÏ¢µ±×÷×Ö·û´®·µ»Ø¡£typeof ·µ»ØÖµÓÐÁùÖÖ¿ÉÄÜ£º "number," "string," "boolean," "object," "function," ºÍ "undefined."
typeof Óï·¨ÖеÄÔ²À¨ºÅÊÇ¿ÉÑ¡Ïî¡£
Ïà¹ØÎĵµ£º
×î½ü×öÒ»¸ö¹«Ë¾µÄÒµÎñϵͳ£¬¹«Ë¾ÒªÇóÄܾ¡¿ÉÄܵÄÓëc/s½üËÆ£¬Ò²¾ÍÊÇÈçc/sÒ»Ñù£¬µã»÷Îı¾¿ò¿ÉÒÔµ¯³ö´ËÏîÄ¿µÄÏà¹ØÄÚÈÝ£¬½øÐÐÑ¡ÔñÊäÈë¡£
ÎÒʹÓÃÁ˵¯³ö´°¿Ú£¬È»ºóÔÚ×Ó´°¿ÚË«»÷Ñ¡ÖÐÏîÄ¿£¬°ÑÑ¡ÖеÄÖµ·µ»Ø¸ø¸¸´°Ìå¡£
ÔÚϵͳ×öÍêÁËÖ®ºó£¬ÔÚ¿Í»§Ê¹ÓõĹý³Ì£¬ÓÉÓÚ¿Í»§Ê¹ÓõÄÊÇ512m ......
ÒÔÇ°ÒòΪ½Ó´¥µÄÏîÄ¿£¬Óõ½javascriptµÄµØ·½£¬±¾È˶ÔjavascriptÕâ¸ö¶«Î÷ÈÏʶ²»¹»£¬ÉõÖÁÒÔΪÊÇǰ̨³ÌÐòÔ±µÄ¹¤×÷¡£×î½ü×öµÄÏîÄ¿ÀïÃæÓõ½Á˺ܶàÕâÖֽű¾ÓïÑÔ£¬²Å·¢ÏÖÕâ¸öС¶«¶«ÊµÔÚÊǺܿɰ®£¬ËäÈ»ºÜÌÔÆø£¨²»ÊǺÜÃæÏò¶ÔÏñ£¬²»ÊǺܺõ÷ÊÔ£©£¬µ«ÊÇÖ»ÒªÊÇ×öweb¿ª·¢µÄ£¬¶¼ÄÑÃâÒª½Ó´¥µ½Ëû£¬°ÑÕ⸠......
event.keycode´óÈ«(javascript)
keycode 8 = BackSpace BackSpace
keycode 9 = Tab Tab
keycode 12 = Clear
keycode 13 = Enter
keycode 16 = Shift_L
keycode 17 = Control_L
keycode 18 = Alt_L
keycode 19 = Pause
keycode 20 = Caps_Lock
keycode 27 = Escape Escape
keycode 32 = space space
......
1. ³¤¶ÈÏÞÖÆ
<script>
function test()
{
if(document.a.b.value.length>50)
{
alert("²»Äܳ¬¹ý50¸ö×Ö·û£¡");
document.a.b.focus();
return false;
}
}
</script>
<form name=a onsubmit="return test()">
<textarea name="b" cols="40" wrap="VIRTUAL" rows="6"></textarea& ......