Javascript ÏÔʾ±êǩҳЧ¹û
ҪʵÏÖÕâ¸ö¹¦ÄܹؼüÊÇÒªÀí½â¿éµÄdisplayÊôÐÔ¡£Ò»¸ö¿éµÄdisplayÊôÐÔÉèΪnone£¬¾ÍÏ൱ÓÚÕâ¸ö¿é²»´æÔÚ¡£ËùÒÔ½«ÒªÏÔʾµÄ¶à¸ö¿éµÄdisplayÊôÐÔÉèΪnone,ÔÙ¸ù¾ÝÐèÒª½«ÒªÏÔʾµÄ¿éµÄdisplayÊôÐÔÉèΪblock¾Í¿ÉÒÔ×ö³ö±êǩҳЧ¹ûÁË¡£
£¨1£© ½¨±êÇ©ÌâÒÔ¼°¸÷±êÇ©ÌâËù¶ÔÓ¦µÄÏÔʾÄÚÈÝ£º
<span id="span1">±êÇ©Ò³Ò»</span><span id="span2">±êÇ©Ò³¶þ</span><span id="span3">±êÇ©Ò³Èý</span>
<div id="div1">¿éÒ»</div><div id="div2">¿é¶þ</div><div id="div3">¿éÈý</div>
£¨2£© ÉèÖñê¸÷<span>ºÍ<div>µÄÏÔʾ·½Ê½£ºÖ÷Òª½«div1µÄdisplayÊôÐÔÉèΪblock£¬div2ºÍdiv3µÄdisplayÊôÐÔÉèΪnone¡£¼´Ä¬ÈÏÏÔʾdiv1¡£
£¨3£© ÈÃspanµÄonmousemoveÏÔʾ¸÷×ԵıêÇ©¿é¡£È磺<span id="span1" onmousemove="showdiv(0)"> <span id="span2" onmousemove="showdiv(1)"> <span id="span3" onmousemove="showdiv(2)">
£¨4£© ÓÃjavascriptʵÏÖshowdiv(i)º¯Êý£º
Ê×ÏȽ¨Á¢Á½¸öÊý×飬±£´æspanºÍdivµÄidÃû³Æ£¨²»ÊDZØÐëÕâÑùʵÏÖ£¬µ«ÕâÑùºÜ¼òµ¥¡£¡£¡£¡£¡££©¡£
var spans=new Array(3);var divs=new Array(3);
spans[0]="span1";spans[1]="span2";spans[2]="span3";
divs[0]="div1";divs[1]="div2";divs[2]="div3";
½Ó×ÅÓÃÒ»¸öforÑ»·½«Èý¸ödiv¿éµÄdisplayÊôÐÔÉèΪnone£¬Í¬Ê±½«spanµÄ±³¾°É«ÉèΪĬÈϵı³¾°É«,ÕâÊÇΪÏÂÒ»²½Í»³öÏÔʾËùÑ¡ µÄ±êÇ©Ò³×¼±¸µÄ;
for(var j=0;j<3;j++){
document.getElementById(spans[j]).style.backgroundColor="#E95504";
document.getElementById(divs[j]).style.display="none";
}
×îºó½«¶ÔÓ¦µÄdiv¿éµÄdisplayÊôÐÔÉèΪblock£¬¶ÔÓ¦µÄspanÍ»³öÏÔʾ£º
document.getElementById(spans[i]).style.backgroundColor="#dddddd";£¨iΪ´«Èë²ÎÊý£¬±êʶÊó±êËùÔڵıêÇ©£©
document.getElementById(divs[i]).style.display="block";
£¨5£©¾ßÌåʵÏÖÈçÏ£º
<html>
<head>
<title></title>
<style>
#span1{
display: block;width: 80px;text-align: center;height: 15px;float: left;background-color :#dddddd; margin-left : 5
Ïà¹ØÎĵµ£º
½ñÌìÍ·¶ù¸´²é´úÂ룬½á¹û·¢ÏÖÓеÄÒ³Ã沢ûÓÐÏàÓ¦µÄDOMÔªËØ£¬µ¼Öµ÷ÓÃfuction³ö´í¡£²ÉÓÃJavaScriptÖÐarguments¶ÔÏó¿ÉÒÔºÜÇáËɵĽâ¾öÕâ¸öÎÊÌ⣬¶ø²»ÐèÒªÔÙÈ¥ÅжÏÔªËØÖ®ÀàµÄ¡£so Good£¡
JavaScriptÖÐargumentsº¯Êý¶ÔÏóÊǸöÔÏó´ú±íÕýÔÚÖ´Ðеĺ¯ÊýºÍµ÷ÓÃËüµÄº¯ÊýµÄ²ÎÊý¡£Ê¹Ó÷½·¨£º
[function.]arguments[n ]
ÆäÖÐfunctionÊÇ ......
¡¡javascriptº¯ÊýµÄ²ÎÊýÊÇ¿ÉÑ¡µÄ¡£ËüÓÐÏÂÃ漸¸öÌص㣺
¡¡¡¡£±.ÒòΪjavascript±¾ÉíÊÇÈõÀàÐÍ£¬ËùÒÔ£¬ËüµÄº¯Êý²ÎÊýҲûÓÐÀàÐͼì²éºÍÀàÐÍÏÞ¶¨£¬Ò»Çж¼Òª¿¿±à³ÌÕß×Ô¼ºÈ¥½øÐмì²é¡£
¡¡¡¡£².²ÎÊý¸öÊý²»¶¨¡£¾¡¹ÜÄãÒ²ÔÚÔÚº¯ÊýÉùÃ÷ʱ£¬ÓУ³¸ö²ÎÊý£¬¶øÔÚʵ¼ÊµÄʹÓÃÖУ¬Äã¿ÉÒÔ´«ÈÎÒâ¸ö²ÎÊý¸øÕâ¸öº¯Êý¡£ËüµÄʶ±ð½ö½öÊÇÒÀ¿¿º¯ÊýÃû£¬ÕâÓ ......
indexOf
·µ»ØÔªËØÔÚÊý×éµÄË÷Òý£¬Ã»ÓÐÔò·µ»Ø-1¡£ÓëstringµÄindexOf·½·¨²î²»¶à¡£
Èç¹ûÆäËûä¯ÀÀÆ÷ûÓÐʵÏÖ´Ë·½·¨£¬¿ÉÒÔÓÃÒÔÏ´úÂëʵÏÖ¼æÈÝ£º
Array.prototype.indexOf = function(el, start) {
var start = start || 0;
for ( var i=0; i < this.length; ++i ) {
......
1.²»¹ýÎÒ½ÌÄãÒ»¸öѧ×öÍøÒ³µÄ¼¼ÇÉ
ÿ¿´µ½Ò»¸öƯÁÁµÄÍøÒ³¾Í²é¿´Ï´úÂë
2.¿´ÕÅТÏéµÄÊÓƵ
3¡£´Ó»ù´¡Ñ§Æð¡£È»ºóѧЩ»ù±¾µÄWEB¿ª·¢Ó¦ÓÃ
ÍƼöÒ»¸öÍøÕ¾http://www.ccscript.cn/
¸ÃÕ¾Ïêϸ·ÖÀàJSµÄ»ù´¡,¶ÔÏó,¼«ÆäÓ¦Óã»
¸ÃÕ¾ÓжàÖÖµ±½ñÁ÷ÐеÄJS¿ò¼Ü£»
Õ¾ÄÚÖ÷´òJquery¿ò¼ÜµÄ»ù´¡¼°Ó¦Óã»
°üÀ¨ÌØЧ´úÂëºÍչʾÌØЧ£» ......
Õâ¸öÎÊÌâºÜ¼òµ¥£¬Ö÷ÒªÓÐÏÂÃ漸¸ö֪ʶµã£º
£¨1£© È¡µÃʱ¼ä£ºvar d=new Date();var time=d.toLocaleString()
£¨2£© ÏÔʾÔÚÍøÒ³ÉÏ£¬¼ÙÉèдÔÚÒ»¸ö<span>ÖУ¬ÇÒ¸Ã<span>µÄidΪshowTime:
document.getElementById("showTime").innerHTML ......