Domanda

I have probably found a bug in jQuery with textarea value.

I have a textarea with a placeholder:

<textarea cols=​"20" id=​"Message" name=​"Message" rows=​"2" style=​"width:​500px;​" 
placeholder="Ecrire une note...">​</textarea>​

When I load the content with $.ajax, I set the value with $('#Message').val(data.Message); but nothing appears. I have tried with .val(), .html(), .text(), .append() but ever same behavior, the value is well set in source code but not displayed. If I remove the placeholder, same code is working well.

So, do I remove the placeholder on textarea and manage it with jQuery, or something exist to have a placeholder and set value possible without trick ?

È stato utile?

Soluzione

What is the format of data.Message? The following statement works though.

 $('#Message').val("Works"); 

http://jsfiddle.net/ardeezstyle/ATJgg/

Altri suggerimenti

I have probably found a bug in jQuery with textarea value.

You're a bit pretencious lol.

Anyway, do you have your code inside the basic

$( document ).ready(function() {
// Handler for .ready() called.
});

???

You should use value attribute instead of placeholder. Then get it's text using $('#Message').val()

Ok, this is my fault :/

The container with dropdownlist and textarea was created 2 times, the result goes in the 1st container except the 2nd was visible...

Sorry to bothered you.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top