html - jQuery remove new elements -


i've got html form allows user add more elements form, side of each line of elements, there 'remove' button, button linked jquery call newly added elements aren't removing when button clicked, however, elements hard coded html remove.

here code:

$("[data-action]").each(function(i,a){ $(a).bind('click',function(){     switch ($(a).attr("data-action")) {         case "addqualificationfield":             qual_add_current++;             var qual_add_html = '<div id="addqualification' + qual_add_current + '" class="controls inline" style="margin-top: 5px;">' +                         '<label for="addqualificationtype[' + qual_add_current + ']">type:</label> <input type="text" name="addqualificationtype[' + qual_add_current + ']" id="addqualificationtype[' + qual_add_current + ']" placeholder="e.g. \'a\' level" class="input-small" maxlength="75" /> ' +                         '<label for="addqualificationsubject[' + qual_add_current + ']">subject:</label> <input type="text" name="addqualificationsubject[' + qual_add_current + ']" id="addqualificationsubject[' + qual_add_current + ']" class="input-small" maxlength="75" /> ' +                         '<label for="addqualificationgrade[' + qual_add_current + ']">grade:</label> <input type="text" name="addqualificationgrade[' + qual_add_current + ']" id="addqualificationgrade[' + qual_add_current + ']" class="input-small" maxlength="20" /> ' +                         '<button type="button" class="btn" data-action="removequal" data-qualid="' + qual_add_current + '"><i class="icon-remove"></i></button>' +                     '</div>';             $("fieldset#addqualifications").append(qual_add_html);             break;          case "removequal":             var qual_id = parseint($(a).attr("data-qualid"));             if (confirm("are sure want this?")) {                 $("div#addqualification" + qual_id).remove();             }             break;     }   }); }); 

you have use jquery on method remove dynamically created elements.


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

.htaccess - Matching full URL in RewriteCond -