Javascript Basics Tutorial 2

Gambar 140. ID: JavaScript dapat ditempatkan di body dan head bagian dari halaman HTML. Tag script Dalam HTML, kode JavaScript harus disisipkan di antara tag script pembuka dan tag script penutup. | GB: JavaScript can be placed in the body and head section of an HTML

JavaScript Where To or How Referencing Javascript.

Prior to this matter, I hope you've followed the previous material. If you have not read this material, please go back to the early material first. So you will not be at levels that are too steep.

Learn HTML Basics Structure

Matter CSS Basics

Tutorial Javascript Basics for Beginners

Javascript Basics Tutorial 1

JavaScript can be placed in the body and head section of an HTML page. script tags in HTML, JavaScript code must be inserted between script open tag and script close tag.

Example:

The older examples may use different types of attributes: script type = "text / javascript".

This type attribute is not required. JavaScript is a scripting language default in HTML. JavaScript Functions and Events A JavaScript function is a block of JavaScript code, which can be run when "asked" to.

For example, the function can be executed when an event occurs, such as when the user clicks the button. You will learn more about the functions and events in the next chapter. JavaScript in the head or body You can put a number of scripts in HTML documents. Scripts can be placed in the body or the head HTML pages, or both. Keeping all the code in one place, always a good habit. JavaScript in the head In this example, the JavaScript function is placed in the head HTML pages. This function is invoked (called) when the button is clicked:

Example:

JavaScript in the body In this example, the JavaScript function is placed in the body section of the HTML page. This function is invoked (called) when the button is clicked (when the button is clicked):

Example:

It is a good idea to put the script under the body element. This can improve page load, because the script compilation can slow the screen. external JavaScript Scripts can also be placed in an external file: myScript.js

External scripts practical when the same code is used in many different web pages. js JavaScript file has the file extension. To use the external script, put the script file name in the src (source) attribute of the script tag:

Example:

You can place an external script reference in the head or body tags as you want. The script will behave as though it is located exactly where the script tag is located.  The external script can not contain the script tag.

Advantages external JavaScript Placing JavaScripts in external files have several advantages:

  • Separating the HTML and code.
  • It makes HTML and JavaScript easier to read and maintain.
  • JavaScript file cache can speed up page load

Related Posts

Javascript Basics Tutorial 1

About Javascript and Example Please before you read this tutorial, first read the previous tutorial about: Learning HTML Structure...

Author

Administrator

17 November 2016

Hey..... Apa kabar? Semua artikel dan layanan yang kami sediakan di sini semata-mata untuk kepentingan pengguna dan klien. Jadi jika Anda merasa membutuhkan pelayanan kami silahkan jangan ragu untuk menghubungi. Kami juga bersedia untuk melayani konsultasi online melalui media sosial, melalui komentar dan melalui halaman testimonial yang telah kami sediakan. Selain itu Anda juga dapat menggunakan kontak form yang tersedia.

Jika apa yang anda dapatkan dari situs ini bermanfaat, silahkan dukung dengan like dan share . Terimakasih telah berkunjung, silahkan kembali kapanpun anda merasa membutuhkan layanan yang kami sediakan.

Ingin berbagi dengan multibisnisindo dan memberikan kontribusi....? Tulis pengalamanmu Di Sini

Terimakasih
Best Regard

Tidak ada komentar terkait posting ini, Ingin memberi komentar?