I am running jquery 1.3.2 and when I try to retrieve the value of a <textarea> I get a TypeError: $(...).val is not a function. The function outside the .click() works fine, but when I click the link, I get the error.
var textbox = 'textarea#Comments';
var get = $(textbox).val();
alert(get);
$(textbox).after('<a href="#" id="link">Get text</a>');
$('a#link').click(function() {
var get = $(textbox).val();
alert(get);
});
Edit: The problem was caused by firefox javascript console. Putting the code on the site and running it fixed the issue.
Try this,