admin管理员组文章数量:1279018
I have a line of jquery that is inserting a div before another div that is already on the page using jQuery's before method:
$("#sendEmail").before('<div id="response"><h1>Success</h1><p>Your email was sent.</p></div>');
I want the new div to fade in, so I tried to bine the methods in two different ways, but both did not work correctly. Here is what I tried:
$("#sendEmail").before('<div id="response"><h1>Success</h1><p>Your email was sent.</p></div>').fadeIn("slow");
That didn't work cause it was trying to fade out the #sendmail div and not the one i was inserting. Here's the other attempt I made:
$("#sendEmail").before('<div id="response"><h1>Success</h1><p>Your email was sent.</p></div>');
$("#response").fadeIn("slow");
That also didn't work since the #response div is already inserted when I try to fade it in, so nothing happens.
I feel like I'm really close, but I can't figure it out. Can someone help?
I have a line of jquery that is inserting a div before another div that is already on the page using jQuery's before method:
$("#sendEmail").before('<div id="response"><h1>Success</h1><p>Your email was sent.</p></div>');
I want the new div to fade in, so I tried to bine the methods in two different ways, but both did not work correctly. Here is what I tried:
$("#sendEmail").before('<div id="response"><h1>Success</h1><p>Your email was sent.</p></div>').fadeIn("slow");
That didn't work cause it was trying to fade out the #sendmail div and not the one i was inserting. Here's the other attempt I made:
$("#sendEmail").before('<div id="response"><h1>Success</h1><p>Your email was sent.</p></div>');
$("#response").fadeIn("slow");
That also didn't work since the #response div is already inserted when I try to fade it in, so nothing happens.
I feel like I'm really close, but I can't figure it out. Can someone help?
Share Improve this question asked Mar 29, 2009 at 0:17 zeckdudezeckdude 16.2k44 gold badges146 silver badges194 bronze badges3 Answers
Reset to default 7$('<div id="response"><h1>Success</h1><p>Your email was sent.</p></div>')
.hide().insertAfter("#sendemail").fadeIn();
Try adding an extra $() this will call createElement on the response and fade that in. Then it will add the element before the sendEmail element.
$("#sendEmail").before($('<div id="response"><h1>Success</h1><p>Your email was sent.</p></div>').fadeIn("slow"));
Basically what that is expanded to is.
var responseDiv = $('<div id="response"><h1>Success</h1><p>Your email was sent.</p></div>')
.fadeIn("slow");
$("#sendEmail").before(responseDiv);
set a css rule on #response to have display: none
then it won't show until you fade in
本文标签: javascriptHow do I combine the 39before39 method with the 39fadeIn39 method in jQueryStack Overflow
版权声明:本文标题:javascript - How do I combine the 'before' method with the 'fadeIn' method in jQuery? - Stack Ov 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741259215a2367282.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论