I'll-Be-Back I'll-Be-Back - 1 year ago 75
jQuery Question

Remove label from the clone?

When the slot has been cloned, the

are hidden. Only first slot at the top have a
(not hidden).

Currently it is hiding all the labels, how to solve this?

$('.slot-container').on("click", ".btn-add-slot", function(event) {
var slot = $(this).closest('.slot');
copySlot = slot;

$('label', copySlot).hide(); // hide Clone Label


//hide button from this slot


<div class="slot-container">
<div class="slot">
<input type='text' class='address_field' />
<button class="btn-add-slot">
Add Slot +


Answer Source

To solve this you need to call hide() on the label element within the cloned element only. Also note that you can tidy the logic slightly. Try this:

$('.slot-container').on("click", ".btn-add-slot", function(event) {
    var $clone = $(this).closest('.slot').clone().appendTo(".slot-container");        

Updated fiddle

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download