$(document).ready(function () {
$('#add_button').click(function () {
var num = $('.datatable_class').length;// getting number of divs with this class
var newNum = num + 1;// var with plus 1 to the last count of divs
var newElem = $('#input1').clone().attr('id', 'input' + newNum).removeClass('HiddenInput').addClass('.NewInputs').fadeIn(1000);//cloning div and removing the hidden class. adding a visible class
newElem.find('td').attr('id', function () { // finding all td's in this div and assigning new ids
return this.id + '_' + newNum
});
newElem.find('input').attr('id', function () {// finding all inputs in this div and assigning new ids
return this.id + '_' + newNum
});
$('#input' + num).after(newElem);// creating new cloned div and placing after previosly copied div
var Snum = $('.sticker_class').length;// preparing as done above but for the sticker table
var SnewNum = Snum + 1;
var SnewElem = $('#sticker1').clone().attr('id', 'sticker' + SnewNum).removeClass('HiddenSticker').addClass('NewSticker');
SnewElem.find('td').attr('id', function () {
return this.id + '_' + SnewNum
});
$('#sticker' + Snum).after(SnewElem);
});
});
$('#sticker_button').click(function () {// button to hide tables and show sticker tables
$("div[name^='divtable']").hide();
$("div[class^='NewSticker']").show();
});
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Fiddle Pages
Your fiddles accessible under a custom domain and a vanity path.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!