How do I get the text from a dynamically created textarea using Jquery?
Ok so I have this:
$('a[name=writecommentsmodal]').live('click',function(e) {
e.preventDefault();
var date=new Date();
var currdate=date.getYear()+" "+date.getMonth+" "+date.getDate();
var comm=new addComment("",fullname,currdate,$ ***("#inputspace2").text()) ***;
comm.appendComment($(".wallpostcontainer"));
});
And I'm trying to get the text from inputspace2. inputspace2 is dynamically created when button is pushed (that button is 'a[name=writecommentsmodal]'). That button also happens to be dynamically created from a different button click (hence the use of live), but I digress. That inputspace2.开发者_运维百科text is empty when I click on the modal button. How do I access it? In firebug its "". I'm thinking maybe having to use live again but I'm no
For text areas, use .val()
instead of .text()
.
Using textContent
, innerText
, outerHTML
or innerHTML
on a textarea returns the contents of the text field as defined in the HTML. User's modifications of the content are only visible through the .value
property.
精彩评论