jQuery 一起追加和滑动 [英] Append and Slide together jQuery

查看:21
本文介绍了jQuery 一起追加和滑动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

I have this append method which I made to add more input boxes until there is 10 of them which will disable into making more.

i = 0;
$('#add-link').click(function() 
{   
    if(i < 9)
    {
        $('.insert-links').append('<div class="new-link" name="link[]"><input type="text" /></div>');
        i++;
    }
    if(i == 9)
    {
        $('#add-link').html('');    
    }
});

Although, it's good. However, I want to implement a slideDown when appended, I've tried doing this:

$('.insert-links').append('<div class="new-link" name="link[]"><input type="text" /></div>').slideDown("fast");

Which doesn't work at all.

解决方案

Like SimpleCoder's solution, but in only one line using appendTo():

$('<div style="display: none;" class="new-link" name="link[]"><input type="text" /></div>').appendTo($('.insert-links')).slideDown("fast");

Demo: http://jsfiddle.net/V4SVt/336/

这篇关于jQuery 一起追加和滑动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆