Jquery method runs but doesn't alter the case of the textbox text -


I have written a small jquery method that the text box content on a keypress event of a text box should be changed to upper case. The method shows fire and fast alerts, but the case of the text never changes in the upper case.

Here is a jquery method

  $ ("# testtext"). Bind ('keyboard', function (e) {var mytext = $ ("# testtext"). Val (); $ (mytext) .text ($ (mytext) .text (). ToUpperCase ();; Alert (MyText ); $ ("#texttext"). Val () = $ (mytext);}); Can someone help me and tell me what is wrong ??   

To reference an element that gets the event, you can type the this Use.

What you were doing was taking the lesson, and it was $ () as you were selecting an element.

Then you were using an inappropriate use of .val () = $ (mytext) .

/ Em> value.

  $ ("# testtext"). Set the value of the bind ('key', function (e) {// value mytext = $ (this) .val (); // input $ (this) .val (mytext.toUpperCase ()); });   

  • Edit: To reuse the used jQuery objects Always a good idea is to get binding ('key', function (e) {var $ th = $ (this); // the value of the input mytext =

      $ ("# testtext "). $ Th.val (); // value determines $ th.val (mytext.toUpperCase ());};  

Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -