2017-04-27 7 views

答えて

0

いくつかのファイルアップロードフィールドを追加します。

<p class="hide">[file file-01]</p> 
<p class="hide">[file file-02]<a class="del_file" href="#">Delete</a></p> 
<p class="hide">[file file-03]<a class="del_file" href="#">Delete</a></p> 

<a href="#" class="add_file">Add file </a> 

次に、このスクリプトを追加します(あなたはjQueryのを必要とする)

jQuery(document).ready(function($){ 

    //hide all inputs except the first one 
    $('p.hide').not(':eq(0)').hide(); 

    //functionality for add-file link 
    $('a.add_file').on('click', function(e){ 
     //show by click the first one from hidden inputs 
     $('p.hide:not(:visible):first').show('slow'); 
     e.preventDefault(); 
    }); 

    //functionality for del-file link 
    $('a.del_file').on('click', function(e){ 
     //var init 
     var input_parent = $(this).parent(); 
     var input_wrap = input_parent.find('span'); 
     //reset field value 
     input_wrap.html(input_wrap.html()); 
     //hide by click 
     input_parent.hide('slow'); 
     e.preventDefault(); 
    }); 
    }); 

あなたのフィールドを隠すことができます!

関連する問題