I believe you can use $("p").toggle("slow"); and it will achieve the result you are after, no need for 2 seperate functions.
On 6/15/07, Giovanni Battista Lenoci <[EMAIL PROTECTED]> wrote:
Hi, I'm a newbie in jquery please be patient :-) I'm playin with jquery mixing some tutorials. I'm trying to open a <p> with some text within with the animation control, and a link. Then when I opened the <p> I want to change the behaviour of the link. When I click on the link I do the animation, and then call the changebutton function that would be change the link in something that can close the opened <p> I've noticed that the function passed in the click event seems to be appended instead of replaced. I can't find in the docs where this beahviour is explained. Please apologize me for my bad english. Here some code: <html> <head> <script type="text/javascript" src="js/jquery.js"></script> <script type="text/javascript"> function changebutton() { $("#switch").click(function() { alert('what I\'m doing?'); /* $("p").animate({ height: 'toggle', opacity: 'toggle' }, "slow", changebutton);*/ }); } $(document).ready(function() { $("#switch").click(function() { $("p").animate({ height: 'show', opacity: 'show' }, "slow", changebutton); }); }); </script> <style> p { border:1px solid red; width:300px; display:none; } </style> </head> <body> <a href="#" id="switch">Open</a> <p> Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum. Typi non habent claritatem insitam; est usus legentis in iis qui facit eorum claritatem. Investigationes demonstraverunt lectores legere me lius quod ii legunt saepius. Claritas est etiam processus dynamicus, qui sequitur mutationem consuetudium lectorum. Mirum est notare quam littera gothica, quam nunc putamus parum claram, anteposuerit litterarum formas humanitatis per seacula quarta decima et quinta decima. Eodem modo typi, qui nunc nobis videntur parum clari, fiant sollemnes in futurum. </p> </body> </html>