Question: Concerning the Implementation of getting text content and changing the style of an altar friend, the altar friend text

Source: Internet
Author: User

Question: Concerning the Implementation of getting text content and changing the style of an altar friend, the altar friend text

Requirement: click "button" to obtain the selected content in the input box, so that the selected content becomes red,

Implementation: The Code is as follows:

   1: <!DOCTYPE HTML>
   2: 
   3:     
   4:         <meta http-equiv="content-type" content="text/html;charset=utf-8">
   5:         <title>Test</title>
   6:     <style type="text/css">
   7:         div{
   8:           display: none;
   9:         }
  10:     </style>
  11:     
  12:     <body>
  13:     <input type="text" id="txt" value="" /> 
14: <input type = "button" value = "get the value in the text box" id = "btn" onclick = "getText ();"/>
  15:     <div id="showText">
  16:       
  17:     </div>
  18:     <script type="text/javascript">
  19:       function getText () {
  20:         var showText = document.getElementById("showText");
  21:         showText.style.display = "block";
  22:         showText.style.color = "red";
  23:         showText.innerHTML=document.getElementById("txt").value;
  24:       }
  25:     </script>
  26:     </body>
  27: 

Effect:


If you have a better method, please contact us. Sorry for the shortcomings.


Source: http://www.ido321.com/539.html



How can I get the content before the text changes to a textbox?

You can declare a string as the content of the previous Temporary change. In the textchanged event process, assign the current value to this temporary variable. In the next textchanged event, this temporary variable is the content before the change. Can this happen?
 
Java interface to obtain a JTextFiled Content Method

Increase the amount of your code .. Is it possible to calculate money based on the number of lines of code...

Simplified. It is no different from getText...
Public String getString (JTextFiled t ){
Return t. getText ();
}
You can do it yourself... it's totally unnecessary...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.