I'm trying to get the String value out of a text area using
var name = $('textarea#myTextBox').val();
However, this seems to output undefined. I know this because I have a check in my JS after this code that says name = "5"+name+"4";
I then send name
to a C++ file using Awesomium, and the name is processed through the below line:
String name = Convert::toString(params[L"name"].toString());
When I see what my name is set to, it reads "5undefined4"
EDIT: My CSS is simply this:
#myTextBox {
position: absolute;
top: 78%;
left: 40%;
}
I've h开发者_如何学Goad my html set as:
<textarea id="myTextBox" rows="1" col="20" maxlength="18"></textarea>
Which makes the text area "listen" to the CSS and be placed in the correct position, but I get null
as my string.
I've also tried:
<div class="myTextBox">
<textarea id="nameBox" rows="1" col="20" maxlength="18"></textarea>
</div>
Which then the textarea does not listen to the CSS and it still returns null
What does
alert($('textarea#myTextBox').length);
say? – alex
@alex It says 0 – Briz
Your selector is incorrect.
For that selector to work, your HTML should look like...
<textarea id="myTextBox" rows="1" cols="1" name="something"></textarea>
The id
attribute is the important one.
The way I would use jquery with id is to use $('#controlId')
did you try $('#myTextBox').val() ?
精彩评论