highlighting text using javascript

In the following example, we call a javascript function highlight the text in a textbox. The code also changes the color of document on page load using a custom javascript function changeColor()

<!DOCTYPE html>
    <title>Untitled document</title>
  <meta charset="utf-8" />

    <script language="javascript" type="text/javascript">

        function changeColor()
            document.bgColor = 'green';

        function myfunction1()

<body onload="changeColor();">

<form id="frm" name="frm" method="post" action="">
    <input id="txt" name="txt" type="text" value="pakistan" />
    <input id="btn" name="btn" type="button" onclick="myfunction1();" value="Click Here" />




Add a Comment

Your email address will not be published. Required fields are marked *