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

Ashish Mehra
Courses Plus Student 31 Pointsis this possible to use toggle here ?
$(".intro_image a").click(function(){
$("#welcome").toggle();
$("#intro").css("top","120px");//here i want to use toggle
});
3 Answers

Jason Anello
Courses Plus Student 94,610 PointsIn that case, I recommend that you add a class rule to your css that contains all the styles you want to toggle and then use the toggleClass()
method on that element. http://api.jquery.com/toggleClass/
.class-name {
top: 120px;
/* whatever else you need */
}
jQuery -
$("#intro").toggleClass("class-name");
Basically, adding and removing the class will have the effect of adding and removing the styles.
Replace class-name with whatever class name you want to use.
Let me know if I've misunderstood what you're trying to do.

Jason Anello
Courses Plus Student 94,610 PointsAlso, keep in mind that top
will be ignored if you don't set position
to something other than static
. e.g. absolute, relative, or fixed.
Do you have this in your #intro
styling?

Adrian Patrascu
15,279 PointsHi Ashish,
Yes it should be possible, but I believe from the code you have written that the welcome id element will be toggled. Please see the following documentation on toggle: http://www.w3schools.com/jquery/eff_toggle.asp and the example put in practice: http://www.w3schools.com/jquery/tryit.asp?filename=tryjquery_eff_toggle
Thank you, Adrian

Ashish Mehra
Courses Plus Student 31 PointsJason Anello , yes i want to do same
Jason Anello
Courses Plus Student 94,610 PointsJason Anello
Courses Plus Student 94,610 PointsHi Ashish,
Do you mean that you want to apply and remove that css each time the anchor tag is clicked?