Requisitos: Clique no botão para obter o conteúdo selecionado na caixa de entrada, para que o conteúdo selecionado fique vermelho.
Implementação: o código é o seguinte
<! Doctype html> <html> <head> <meta http-equiv = "content-type" content = "text/html; charset = utf-8"> <title> test </title> <style type = "text/css"> divis {Display: NENHE; <input type = "button" value = "Obtenha o valor na caixa de texto" id = "btn" onclick = "getText ();"/> <div id = "showText"> </div> <script type = "text/javascript"> function getText () {varaText = document.getElementById ("ShowText"; "block"; showtext.style.color = "Red"; showtext.innerhtml = document.getElementById ("txt")Efeito: