I'm working on a project where I have different sets of div like heading, text, image etc..
Upon clicking I want to append input boxes for that relevant numbers of divs.
You can see working fiddle here : http://jsfiddle.net/UN62E/
This script does a job for me but I need improvement with this script.
This is how part of my script look like :
var eltofind = "heading";
if($(this).find("." + eltofind).length != 0){
var eltoget = $(this).find("." + eltofind);
$(eltoget).each( function(index) {
var item = $('input.' + eltofind + ':first').clone();
var count = (index +1);
var getting = eltofind + "-" + count;
item.addClass(getting);
item.appendTo('#input');
});
}
Currently I'm repeating whole script for individual sets of div. Is there a way to call all sets of divs within array? for example :
var eltofind = ["heading", "text", "image"]
& call them within each function ?
My jQuery skills aren't that good & Any help would be appreciated.