JavaScriptʼþðÅݼò½é¼°Ó¦ÓÃ
Ò»¡¢Ê²Ã´ÊÇʼþðÅÝ
ÔÚÒ»¸ö¶ÔÏóÉÏ´¥·¢Ä³Ààʼþ£¨±ÈÈçµ¥»÷onclickʼþ£©£¬Èç¹û´Ë¶ÔÏó¶¨ÒåÁË´ËʼþµÄ´¦Àí³ÌÐò£¬ÄÇô´Ëʼþ¾Í»áµ÷ÓÃÕâ¸ö´¦Àí³ÌÐò£¬Èç¹ûûÓж¨Òå´ËÊ ¼þ´¦Àí³ÌÐò»òÕßʼþ·µ»Øtrue£¬ÄÇôÕâ¸öʼþ»áÏòÕâ¸ö¶ÔÏóµÄ¸¸¼¶¶ÔÏó´«²¥£¬´ÓÀïµ½Í⣬ֱÖÁËü±»´¦Àí£¨¸¸¼¶¶ÔÏóËùÓÐͬÀàʼþ¶¼½«±»¼¤»î£©£¬»òÕßËüµ½´ïÁË¶Ô Ïó²ã´ÎµÄ×²ã£¬¼´document¶ÔÏó£¨ÓÐЩä¯ÀÀÆ÷ÊÇwindow£©¡£
´ò¸ö±È·½Ëµ£ºÄãÔڵط½·¨ÔºÒªÉÏËßÒ»¼þ°¸×Ó£¬Èç¹ûµØ·½Ã»Óд¦Àí´ËÀà°¸¼þµÄ·¨Ôº£¬µØ·½Ïà¹Ø²¿ÃÅ»á°ïÄã¼ÌÐøÍùÉϼ¶·¨ÔºÉÏËߣ¬±ÈÈç´ÓÊ춵½Ê¡¼¶£¬Ö±ÖÁµ½ÖÐÑë·¨Ôº£¬×îÖÕʹÄãµÄ°¸¼þµÃÒÔ´¦Àí¡£
¶þ¡¢Ê¼þðÅÝÓÐʲô×÷ÓÃ
£¨1£©Ê¼þðÅÝÔÊÐí¶à¸ö²Ù×÷±»¼¯Öд¦Àí£¨°Ñʼþ´¦ÀíÆ÷Ìí¼Óµ½Ò»¸ö¸¸¼¶ÔªËØÉÏ£¬±ÜÃâ°Ñʼþ´¦ÀíÆ÷Ìí¼Óµ½¶à¸ö×Ó¼¶ÔªËØÉÏ£©£¬Ëü»¹¿ÉÒÔÈÃÄãÔÚ¶ÔÏó²ãµÄ²»Í¬¼¶±ð²¶»ñʼþ¡£
¡¾¼¯Öд¦ÀíÀý×Ó¡¿
<div onclick=”eventHandle(event)” id=”outSide” style=”width:100px; height:100px; background:#000; padding:50px”>
<div id=”inSide” style=”width:100px; height:100px; background:#CCC”></div>
</div>
<script type=”text/javascript”>
//±¾Àý×ÓÖ»ÔÚÍâÃæºÐ×Ó¶¨ÒåÁË´¦Àí·½·¨£¬¶øÕâ¸ö·½·¨Ò»Ñù¿ÉÒÔ²¶»ñµ½×ÓÔªËصã»÷ÐÐΪ²¢´¦ÀíËü¡£¼ÙÉèÓгÉǧÉÏÍò×ÓÔªËØÒª´¦Àí£¬ÄѵÀÎÒÃÇҪΪÿ¸öÔªËؼӓonclick=”eventHandle(event)””£¿ÏÔȻûÓÐÕâÖÖ¼¯Öд¦ÀíµÄ·½·¨À´µÄ¼òµ¥£¬Í¬Ê±ËüµÄÐÔÄÜÒ²ÊǸü¸ßµÄ¡£
function eventHandle(e){
var e=e||window.event;
var obj=e.target||e.srcElement;
alert(obj.id+‘ was click‘)
}
</script>
£¨2£©Èò»Í¬µÄ¶ÔÏóͬʱ²¶»ñͬһʼþ£¬²¢µ÷ÓÃ×Ô¼ºµÄרÊô´¦Àí³ÌÐò×ö×Ô¼ºµÄÊÂÇ飬¾ÍÏñÀÏ°åÒ»ÏÂÃüÁ¸÷×ÔÔ±¹¤×ö×Ô¼º¸ÚλÉϵŤ×÷È¥ÁË¡£
¡¾Í¬Ê±²¶»ñͬһʼþÀý×Ó¡¿
<div onclick=”outSideWork()” id=”outSide” style=”width:100px; height:100px; background:#000; padding:50px”>
<div onclick=”inSideWork()” id=”inSide” style=”width:100px; height
Ïà¹ØÎĵµ£º
JavaScript½âÎö¶ÁÈ¡XMLÎļþ£¬Ö÷Òª¾ÍÊǼÓÔز¢½âÎöXMLÎļþ£¬È»ºó¾Í¿ÉÒÔ²âÊÔ½âÎöµÄXMLÎļþµÄÄÚÈÝ£¬´òÓ¡Êä³öÀ´¡£
±àдÁËÒ»¸öJavaScriptµÄÀàÀ´ÊµÏÖ¶ÁÈ¡Ò»¸öXMLÎļþÖеÄÊý¾Ý£¬ÊµÏÖ´úÂëÈçÏÂËùʾ£º
<mce:script type="text/javascript"><!--
/**
* @author Shirdrn
*/
function XMLDoc(){}; // ¶¨ÒåÒ»¸öXM ......
Ñ¡ÔñÔªËØ£ºdocument.getElementsByTagName£¬document.getElementsById,document.getElementsByName¡£
firstChild,lastChild,nextSibling£¬previousSibling
´´½¨ÔªËØ£ºdocument.createElement(),appendChild();
ɾ³ýÔªËØ£ºremoveC ......
javascript²¶»ñ´°¿Ú¹Ø±ÕʼþÓÐÁ½ÖÖ·½·¨
1.ÓÃjavascriptÖØж¨Òå window.onbeforeunload() ʼþ
ÔÚjavascriptÀﶨÒåÒ»¸öº¯Êý¼´¿É
function window.onbeforeunload() { alert("¹Ø±Õ´°¿Ú")}
alert()ʼþ½«»áÔڹرմ°¿ÚÇ°Ö´ÐУ¬ÄãÒ²¿ÉÒÔÓû§¾ö¶¨ÊÇ·ñ¹Ø±Õ´°¿Ú
function window.o ......
JavaScript ¿ÉËãÊÇÊÀ½çÉÏ×îÁ÷Ðеıà³ÌÓïÑÔ£¬ËüÔø±» Web ¿ª·¢Éè¼ÆʦÌùÉÏجÃεıêÇ©£¬ËäÈ»ÕæÕýµÄجÃÎÆäʵÊÇ DOM API£¬Õâ¸ö±»´óÁ¿µÄ¿ª·¢ÓëÉè¼ÆʦËæÊÖÄéÀ´ÔöÇ¿ËûÃÇµÄ Web Ç°¶ËµÄ½Å±¾ÓïÑÔ£¬Èç½ñÔ½À´Ô½±»ÖØÊÓ£¬ËäÔòÈç´Ë£¬JavaScript ÈÔȻӵÓкܶàÈÃÈ˷ѽâµÄ¶«Î÷¡£
1. ËüÒÔ Java ÃüÃû£¬µ«²¢²»ÊÇ Java
Ëü×î³õ½Ð Mocha£¬ ½ÓןÄÃûÎ ......
֮ǰ¿´ÁËÓйØÄäÃûº¯ÊýµÄµ÷Ó㬸оõÓбØÒªºÍ´ó¼Ò·ÖÏíһϡ£
¹ØÓÚʲôÊÇÄäÃûº¯Êý£¬¼°Ëü´øÀ´µÄÓÅÊÆÔÚ±¾ÎľͲ»ÉÁË£¬ÏÈÅ׳öÒ»¸ö³£ÓõÄÄäÃûº¯Êý£º
(function(){alert('yo')})()
ºÜ¶àͬѧ֪µÀÔõôÓÃÕâÖÖÄäÃûº¯Êý£¬È´»òÐí²¢²»Ã÷°×ΪʲôÕâÑùд¾ÍÄܹ»µ÷ÓÃÄäÃûº¯Êý¡£Ò²ÐíÖªµÀºóÃæµÄÔ²À¨ºÅÊÇÖ´ÐÐÇ°ÃæµÄº¯Êý£¬¶ø²¢²»Çå³þÇ°ÃæµÄÔ² ......