Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
187
rated 0 times [  188] [ 1]  / answers: 1 / hits: 24125  / 9 Years ago, tue, may 5, 2015, 12:00:00

I've read the other examples where toLowerCase is undefined but I still don't understand. Can anyone explain why my function won't work?





var changeTitle = function() {
var loanTitle = $(this).val();
$(this).prev().text(loanTitle);
};

<h2>Loan One</h2>
<input type=text onkeypress=changeTitle() maxlength=25 />




More From » jquery

 Answers
10

In your function, the this object refers to the window and not the input field. Update your onkeypress code to the following:



<input type=text name=loanName onkeypress=changeTitle.call(this) class=loanNameV1 qForms maxlength=25 placeholder=Loan Name />

[#66748] Saturday, May 2, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
desiraeleandrah

Total Points: 202
Total Questions: 111
Total Answers: 115

Location: Macau
Member since Mon, Nov 16, 2020
4 Years ago
;