Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Fernando Jimenez
Courses Plus Student 8,455 PointsWage Calculator nor working
all I want to do right now is to check the value of annualincome though the input tag. but for some reason it doesn't console.log the value of annualincome.
$( document ).ready(function() {
$("#anualtype").submit(function(e){
e.preventDefault();
let annualincome = this.val();
console.log(annualincome);
});
const ferderalIncome = (5.17)/100;
const socialSecurity = (6.20)/100;
const medicare = (1.45)/100;
const utahStateIncome = (4.60)/100;
});
1 Answer
Hakim Rachidi
38,491 PointsHi Fernando,
In your case the this is not a jQuery object so you can not call jQuery methods on it. You have to options:
- Call the jQuery method with this which is the input element
$("#anualtype").submit(function(e){
e.preventDefault();
let annualincome = $(this).val();
console.log(annualincome);
});
- Use the value property on the input element
$("#anualtype").submit(function(e){
e.preventDefault();
let annualincome = this.value;
console.log(annualincome);
});
Hope this helps;