Требования: нажмите кнопку, чтобы получить выбранный контент в поле ввода, чтобы выбранный контент стал красным.
Реализация: код выглядит следующим образом
<! Doctype html> <html> <Head> <meta http-equiv = "content-type" content = "text/html; charset = utf-8"> <tite> test </teal> <style type = "text/css"> div {display: none;} </style> </hoad> <body> <body> <input upt = "text" = "/stype> </hoad> </body> <body> <body> <body> <intult" = "/xyd" </input> </hoad> <body> <fody> <dult> ". type = "кнопка" value = "Получить значение в текстовом поле" id = "btn" onclick = "getText ();"/> <div Id = "showText"> </div> <script type = "text/javascript"> function getText () {var showtext = document.getElementbyId ("showText"); showText.Style.display = "; "Red"; showText.innerHtml = document.getElementById ("txt"). Value;} </script> </body> </html>Эффект: