Technology Programming

How to View a Tag in JavaScript

    • 1). Launch the standard, plain-text editor application that is available on your computer, such as Notepad.

    • 2). Enter the following code into the text editor.

      <html>

      <head>

      <script language="javascript">

      function Inquire(){

      var info=document.getElementById("mytag");

      document.write("<h1>Tag attributes below</h1>");

      document.write("Font color is: "+info.style.color);

      document.write("");

      document.write("Paragraph width is: "+info.style.width);

      document.write("");

      document.write("Font size is: "+info.style.fontSize);

      document.write("");

      document.write("Background color is: "+info.style.backgroundColor);

      }

      </script>

      </head>

      <body>

      <p style="color:red;width:10em;background-color:yellow;font-size:16px" >Here is my tag!</p>

      <p style="color:blue" >Another paragraph</p>

      <INPUT TYPE="button" onClick="Inquire()" value="Click here to view tag attributes" >

      </body>

      </html>

    • 3). Click the "File" menu and select the "Save" option. Save under the file name "test.html."

    • 4). Launch the Web browser that is available on your computer. Click on the "File" menu and select "Open File."

    • 5). Locate the file "test.html" just created, select it and then click on "Open."

    • 6). Click the button labeled "Click here to view tag attributes" to execute the JavaScript function.



Leave a reply