javascript - code using clone() doesn't work in IE -
i have difficulties clone() jquery. doesn't seem work in ie 9+.
is there way of doing ie?
please see below code:
<ul id="template-list"> <li id="template">clone me</li> </ul> <ul id="placeholder"> </ul> <div class="add"> <button class="add-row" type="button" name="submit">add more</button> </div> var maxappend = 1; var listfirst = document.getelementbyid('placeholder'); var listli = listfirst.getelementsbytagname("li"); $( ".add-row" ).click(function(){ maxappend++; console.log(listli.length); if (listli.length<4) { $( "#template-list" ).first().clone().appendto("#placeholder").append('<div class="remove"><button class="remove-row">remove product</button></div>').find('input').val(''); } else { $( "#template-list" ).first().clone().appendto("#placeholder").append('<div class="remove"><button class="remove-row">remove product</button></div>').find('input').val(''); $(".add-row").hide(); }); $( "body" ).on('click', '.remove-row', function(){ $(this).closest('#template-list').remove(); maxappend--; if(maxappend>4) { $(".add-row").show(); } console.log(listli.length); });
Comments
Post a Comment