add_package.js.html 1.2 KB

123456789101112131415161718192021222324252627282930
  1. <script>
  2. $(document).ready(function(){
  3. $('.add-ns-button').click(function(){
  4. var n = $("input[name^=v_ns]").length;
  5. if(n < 8){
  6. var t = $($('input[name=v_ns1]').parents('tr')[0]).clone(true, true);
  7. t.find('input').attr({value:'', name:'v_ns'+(n+1)});
  8. t.find('span').show();
  9. $('tr.add-ns').before(t);
  10. }
  11. if( n == 7 ) {
  12. $('.add-ns').hide();
  13. }
  14. });
  15. $('.remove-ns').click(function(){
  16. $(this).parents('tr')[0].remove();
  17. $('input[name^=v_ns]').each(function(i, ns){
  18. $(ns).attr({name: 'v_ns'+(i+1)});
  19. i < 2 ? $(ns).parent().find('span').hide() : $(ns).parent().find('span').show();
  20. })
  21. $('.add-ns').show();
  22. });
  23. $('input[name^=v_ns]').each(function(i, ns){
  24. i < 2 ? $(ns).parent().find('span').hide() : $(ns).parent().find('span').show();
  25. });
  26. });
  27. </script>
  28. <script src="/js/pages/add.package.js"></script>