extend a dom element, get the loop index