views:

327

answers:

2

I am using jQuery, and I get the contents of a TextArea as follows:

// get the SQL from the text area at the top:
//sql = $("#sql").val();
//sql = $("#sql").text();
sql = $("#sql").attr("value");

<textarea id="sql" rows="9" cols="99"></textarea>

This works fine in all browsers except IE

I have tried several ways, but nothing works in IE

It gives me the message: "Object doesn't support this property or method". There must be a simple way to do this that works in all browsers, right?

A: 

I don't think textarea has a value attribute. I think using .val() should work though.

mgroves
+4  A: 

I see you commented out:

sql = $("#sql").val();

That actually is the correct way to get the text in a TextArea. It works in all browsers.


Make sure that you don't have another HTML element with the same id as the textarea. This could be the source of the error.

ichiban
Thanks, that works.I changed the id and it started to work ( even though there was no duplicate id!,I swear!...just some other ids that start with "sql", but no duplicates....remember this was working in all browsers except IE...still mysterious to me...)
Nick Perkins
@Nick: You should accept this answer if it helped you.
Prestaul