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
Craig Watson
27,930 Points<div>'s fade in but don't fade back out when the field is deselected ?
Hi everyone,
on the "Build an interactive website" course, I've followed along and must have made a little error i cant spot, the code below is supposed to have a div appear when the form field is selected to be filled in, then upon deselecting it should fade the div out:
html
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript">
$("#form span").hide();
$("input, textarea").focus(function() {
$(this).next().fadeIn("slow");
});.blur(function(){
$(this).next().fadeOut("slow");
});.keyup(function(){
//Check all required fields.
});
$("#email").keyup(function(){
//Check for valid email.
})
</script>
All help is appreciated!
1 Answer
Robert Richey
Courses Plus Student 16,352 PointsHi Craig,
When chaining functions, only use a period as the separator. Notice here, the semi-colons have been removed from chaining functions.
$("input, textarea").focus(function() {
$(this).next().fadeIn("slow");
}).blur(function(){
$(this).next().fadeOut("slow");
}).keyup(function(){
//Check all required fields.
});