JavaScript is a client-side programming
- Step 1
Open your HTML page in a text editor. You can use a simple, plain text editor like Notepad to edit JavaScript, or you can use more advanced applications like Notepad++, Visual Studio and Dreamweaver.
- Step 2
Wrap a div tag around the text you want to edit. This allows you to change the font size of a specific area in your Web page without distorting the layout with a global font size change. The code below creates a div named "myDiv":
My website text - Step 3
Create the JavaScript function. To change a font size in your div tag, you need to set the "fontsize" property. The code below changes the div's font size:
function changeSize()
{
document.getElementbyId("myDiv").fontSize = "12px";
} - Step 4
Add a button to the page to let the user choose to change the font size. To add the button and call the new JavaScript function, use the code below:
- Step 5
Save the file and open the page in your Web browser. Test the new code by clicking the button. The font size increases in the div tag.
No comments:
Post a Comment