How to change form text with Jquery but keep it when filled by user? -


(I hope my title is easy, it was difficult to sum.)

Some scripts that change some text based on selected text within a lesson, as you can see here:

The problem is that if a user enters certain text and then another When the radio button clicks, it will remove its text.

What I see in a way changes the gray text, when the user does not fill any text. And if the user removes their text, then it will fill the blank with the text based on the radio button.

You can see your code here:

check to see if Is there a "signal" in the input only the text is changed?

Full example:

  $ (document) .ready (function () {function setText () {var kf = this.title ('' '' '); If (kf.length & lt; 0) returns; if ($ ('$' + this.name + '_text'). Hcl ('signal')) {$ ('' '(' '' '' '' '' ' _txt '). Val (kf [0]) addClass (' signal ');} $ (' # '+ this.name +' _text '). Attr (' title ', kf [0]);} $ (" Input [type = 'text'] "). InputAdineValue (); $ (" input [type = 'radio'] "). Click (set text);});  

By checking the input textbox for this class "gesture" and when it is found then only work by changing the value As the "Focus () is described in the comments of the event, the class removes" gesture "and the blur () event adds it again if no text is available."

Even if I do not have a valid code through the code provided by W3C, then Javascript can be awkward. (Plus all should write valid HTML)

A has also noticed If you include jQuery twice in your code, I suggest You must remove any one of these.


Updated (July 10, 2009): The bug mentioned in the comments below was fixed.


Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -