Copy codeThe Code is as follows: <div id = "msg"> </div>
<Input type = "text" name = "txt" id = "txt"/>
<Script>
// Function executed when the status changes
Function handle ()
{
Document. getElementById ('msg '). innerHTML = document. getElementById ('txt'). value;
}
// If ("\ v" = "v") returns true only under IE, including IE8
// If (/msie/I. test (navigator. userAgent) can also be effectively determined
If ("\ v" = "v "){
// The IE listens to the text box and assigns a function. The function name cannot contain parentheses.
Document. getElementById ('txt '). onpropertychange = handle;
} Else {
// Google Chrome uses the Add event function to add an event to the text box and assign the event to be executed. The method name cannot be enclosed by brackets.
Document. getElementById ('txt '). addEventListener ("input", handle );
}
</Script>