add_dns.js 914 B

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