htmlÔõôŲÓÃjs
html ͨ¹ýÁ½ÖÖÒªÁìŲÓà javascript£ºÊ¹Óôø src ÊôÐ﵀ ±êǩǶÈëÍⲿ javascript Îļþ¡£Ê¹Óò»´ø src ÊôÐ﵀ ±êÇ©Ö±½ÓÄÚǶ javascript ´úÂë¡£
ÔõÑùÓà HTML ŲÓà JavaScript
HTML5 ÒýÈëÁËÖ±½ÓǶÈë JavaScript ´úÂëµ½ HTML ÎĵµÖеķ½·¨£¬ÓÐÒÔÏÂÁ½ÖÖÒªÁ죺
1. ʹÓà <script> ±êÇ©</script>
×î³£¼ûµÄÒªÁìÊÇʹÓôø src ÊôÐ﵀ <script> ±êÇ©£¬ËüÖ¸¶¨ÒªÇ¶ÈëµÄÍⲿ JavaScript Îļþ·¾¶£º</script>
Á¬Ã¦Ñ§Ï°¡°Ç°¶ËÃâ·ÑѧϰÌõ¼Ç£¨ÉîÈ룩¡±£»
<script src="script.js"></script>
µÇ¼ºó¸´ÖÆ
ÈôÊÇÐèÒªÖ±½ÓÔÚÒ³ÃæÖÐÄÚǶ JavaScript ´úÂ룬¿ÉÒÔʹÓò»´ø src ÊôÐ﵀ <script> ±êÇ©£º</script>
<script> // JavaScript ´úÂë </script>
µÇ¼ºó¸´ÖÆ
2. ʹÓÃÄÚÁªÊÂÎñ´¦Öóͷ£³ÌÐò
HTML ÔªËØ»¹Ö§³ÖÄÚÁªÊÂÎñ´¦Öóͷ£³ÌÐò£¬ÔÊÐíÔÚÔªËØÉϽç˵ JavaScript º¯Êý£º
<button onclick="alert('µã»÷ÁË£¡')">µã»÷</button>
µÇ¼ºó¸´ÖÆ
ʹÓÃÒªÁì
ŲÓà HTML ÖÐǶÈëµÄ JavaScript ´úÂëµÄ·½·¨ÈçÏ£º
<script> ±êÇ©£º</script>µ±ä¯ÀÀÆ÷ÆÊÎö HTML ÎĵµÊ±£¬Ëü»á×Ô¶¯Ö´ÐÐ <script> ±êÇ©ÖÐÒýÓÃµÄ JavaScript ´úÂë¡£</script>
ÄÚÁªÊÂÎñ´¦Öóͷ£³ÌÐò£ºµ±Óû§´¥·¢Ö¸¶¨ÊÂÎñ£¨Èçµã»÷£©Ê±£¬ÔªËØÉ쵀 JavaScript º¯Êý½«±»Ö´ÐС£
×¢ÖØÊÂÏî
˳Ðò£ºJavaScript ´úÂ밴˳ÐòÖ´ÐУ¬Òò´ËÈ·±£½« <script> ±êÇ©»òÄÚÁªÊÂÎñ´¦Öóͷ£³ÌÐò°²ÅÅÔÚ׼ȷµÄλÖá£</script>
È«¾Ö±äÁ¿£ºÔÚ HTML ÖÐÄÚǶ JavaScript ´úÂëʱ£¬Çë×¢ÖØËü»á½¨ÉèÈ«¾Ö±äÁ¿£¬Õâ¿ÉÄÜ»áÓëÆäËû¾ç±¾³åÍ»¡£
×î¼Ñʵ¼ù£º½¨ÒéʹÓÃÍⲿ JavaScript Îļþ£¬¶ø²»ÊÇÄÚǶ´úÂ룬ÒÔÔöÇ¿¿Éά»¤ÐԺͿÉÖØÓÃÐÔ¡£
ÒÔÉϾÍÊÇhtmlÔõôŲÓÃjsµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡