Have the following jQuery:
$(document).ready(function() {
var counter = 1;
var maxAppend = 0;
$("#addItem").click(function() {
if (maxAppend >= 10) return;
var task = $('#searchresults').val();
var src = $('#searchresults').find(":selected").attr('data-src');
var $newLi = $("<li><div1><img src='" + src + "'/></div1><div2><input type='text' id='college' name='college' value='" + task + "'/></div2><button class='up'>↑</button><button class='down'>↓</button></li>")
$newLi.attr("id", "newLi" + counter++);
maxAppend++;
$("#tasks").append($newLi);
});
I understand how to dynamically change the id of "li", however, the input within the $newLi variable is throwing me off. I tried setting the input to its own variable, but did not get too far.
In the end, i'd like to get the 'college' input name to become 'college1' upon button click, then 'college2' on the next click - - just like I have done with 'li' element.
Please let me know if I you need further clarification. Thanks.
id="college"?