This is foo that I created in the console using dom selectors:
foo
[<input type="text" maxlength="70" id="authCreateAcctUsernameInput" name="userName" autocomplete="off" autocapitalize="off" autocorrect="off">]
Then, on the back of a question I just asked a few minutes ago, I learned that if I want to get the textContent of a jquery object I must use .text()
.
Foo has some siblings:
<fieldset>
<label class="userName" for="authCreateAcctUsernameInput">Email Address</label>
<input type="text" maxlength="70" id="authCreateAcctUsernameInput" name="userName" autocomplete="off" autocapitalize="off" autocorrect="off">
<span id="authCreateAcctUsernameErrorTxt" class="errorMSG" style="display: block;">Please enter a valid email address.</span>
In order to get "Email Address" from Foo's sibling textContent I tried this:
$(foo).parent().children()[0].text()
But that returned TypeError: undefined is not a function
.
This does "work":
$(foo).parent().children()[0]
<label class="userName" for="authCreateAcctUsernameInput">Email Address</label>
The element is returned. So why can I not add .text()
to get what I need, which is the string "Email Address"?