I am creating elements dynamically based on user input and a count is inremented which relates to the ID of the element. (Basically, every time the user adds an element the ID is element1, element2 etc.
I have an event listener for the elements and when it's clicked I want just the number of the element to be stored in the variable.
This is what I am trying currently but 'NaN' is returned:
var id = parseInt($(this).attr('id'), 10);
If it helps you understand, this is how the elements are being created:
$("<div />")
.attr("id", "input" + listCount + "container")
.attr("class", "inputContainer")
.appendTo("#checkboxContainer");