Sunday, 16 April 2017

jquery - Can this function be done with names rather than IDs?

I came across a function that does exactly what I need to do in my questionnaire, but it operates using an ID and I need to do it by name.



here's the fiddle for it https://jsfiddle.net/HGtmR/4/



    var cloneCount = 1;;
$("button").click(function(){
$('#id')
.clone()
.attr('id', 'id'+ cloneCount++)

.insertAfter($('[id^=id]:last'))
.text('id ' + (cloneCount-1)); //<--For DEMO
});


Here's a fiddle to the section of my form that I'd like to apply it to https://jsfiddle.net/6djnv9u2/7/

No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...