+ 2
How do I make a HTML file?
I would like to practice JavaScript on a computer, but I don't know how?
5 Réponses
+ 5
1) open notepad
2) write some html code + javascript
3) save file with an extension ".html" eg. something.html
4) open file in browser.
+ 5
Save the following content as index.html file.
<!DOCTYPE html>
<html>
<head>
<title>Html with Javascript</title>
</head>
<body>
<h1>Sample Title</h1>
<p>Lorem ipsum</p>
<script>
// Javascscript code here
alert("Javascript run.");
</script>
</body>
</html>
Double click the file to open it on your default browser.
To test your Javascript, just place Javascript code inside script tag. You can output your results using alert() or console.log() (view the results from browser developer console).
More to learn:
Learn how to interact Javascript with HTML elements (DOM) using document.getElementById,
document.getElementsByClassNme, document.getElementsByTagName. and its member functions.
+ 3
To add to @ifl open any browser of your choice i.e Chrome. Click on menu and open developer tools and click on the console tab. There you can practice your JavaScript.
+ 2
console.log("using the console \n is faster than refreshing the page after saved the code ")
0
you can opening Notpad and type anything. in last save to html