ในการใช้งาน JavaScript นั้น จำเป็นต้องใส่โค๊ด ให้อยู่ระหว่างแท็ก <script> และ </script> โดยตัวคำสั่ง JavaScript นี้จะอยู่ในส่วนแท็ก <head> และ <body> ของเอกสาร HTML เช่น
JavaScript ในแท็ก <body> ตัวอย่างเช่น
<html>
<body>
<script>
document.write("<p>Learn the basic programming Javascript with </p>");
document.write("<h1>www.mindphp.com</h1>");
</script>
</body>
</html>ผลลัพธ์คือ

การใส่คำสั่ง Javascript นั้นอาจใส่ในส่วนแท็ก <head> และ <body> แท็กใดแท็กหนึ่งแล้ว หรือ ทั้งใน <head> และ <body> พร้อมๆกันก็ได้
คลิกเพื่อดู demo file javascript
ข้อมูลอ้างอิง
http://www.w3schools.com
0 ความคิดเห็น:
แสดงความคิดเห็น