English 中文(简体)
页: 1
原标题:Append and Slide together jQuery

我采用了这一推测方法,在其中10个箱子无法投入使用之前添加更多的投入箱。

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(  );    
    }
});

虽然如此,它还是好了。 然而,我想在后面附上一个幻灯片,我试图这样做:

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

哪怕是工作。

最佳回答

同简单的Coder解决方案一样,但只有一行使用appendTo():

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

Demo:

问题回答

尽管简单的Coder方案是完全有效的,但我还是这样:

i = 0;
$( #add-link ).click(function() {   
    if(i < 9) {
        $( .insert-links ).append( <div style="display: none;" class="new-link link_  + i +  " name="link[]"><input type="text" /></div> );
        $( .link_  + i).slideDown("fast");
        i++;
    }
    if(i == 9) {
        $( #add-link ).fadeOut( 200 );
    }
});

原因是,每个链接<代码>input将获得以第二类形式提供的识别资料,如果有人想去除某项内容,则如果意外地增加不止一种需要,则这种识别将非常有用。 我还对<代码>add-link增添了一个缺陷。 因此,用户没有混淆它刚刚消失。 当然,这只是一个个人信条的问题,但我认为这更加方便用户。

希望这一帮助。





相关问题
getGridParam is not a function

The HTML: <a href="javascript:void(0)" id="m1">Get Selected id s</a> The Function: jQuery("#m1").click( function() { var s; s = jQuery("#list4").getGridParam( selarrrow )...

selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

jQuery cycle page with links

I am using the cycle plugin with pager functionality like this : $j( #homebox ) .cycle({ fx: fade , speed: fast , timeout: 9000, pager: #home-thumbs , ...

jquery ui dialog opens only once

I have a button that opens a dialog when clicked. The dialog displays a div that was hidden After I close the dialog by clicking the X icon, the dialog can t be opened again.

jConfirm with this existing code

I need help to use jConfirm with this existing code (php & Jquery & jAlert). function logout() { if (confirm("Do you really want to logout?")) window.location.href = "logout.php"; } ...

Wrap text after particular symbol with jQuery

What I m trying to do, is wrap text into div inside ll tag. It wouldn t be a problem, but I need to wrap text that appears particularly after "-" (minus) including "minus" itself. This is my html: &...

热门标签