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
Jake Salo
13,175 PointsWhy is this jQuery returning a TypeError?
I have this jQuery method chain and it says that 'undefined is not a function'
$('.button:visible, .value:visible').get(0).keydown(function( event ) {
if(event.which === 38) {
event.preventDefault();
$('.flex1-5').focus();
}
});
Can you not use .get() and .keydown() one after another? Or is it the fact that Im passing in multiple selectors? Cheers.
1 Answer
Steven Parker
243,632 PointsThe jQuery "get" function returns a DOM element, but DOM elements do not have a "keydown" method. So no, you can't chain those particular methods.
Perhaps you meant to use "eq" instead of "get".
Jake Salo
13,175 PointsJake Salo
13,175 PointsAh yeah that makes sense - thanks a lot, I'll give it a go.