1
I have this HTML that has the id that is inserted in the loop...
<div class="item-total elemento" id = ${id}>
Therefore, I have this function:
$(document).on('touchstart', '.elemento', function (){
});
In this '.element' actually, I wanted to do something like '.elemento > id'
of the element I clicked, remembering that this function is outside the loop of repetition... has some way of doing this?
I didn’t get it right, each of the
div
should perform a different function? so you want to do a loop by ID?– h3nr1ke
@h3nr1ke in reality no. He will do the same thing. Only then when I do it that way he applies it to everyone, and I just want him to do it in the target element.
– user131623
Got it, so just use the
$(this)
within the function, for example,$(this).addClass("active");
, only the clicked item will change, other items will not.– h3nr1ke
There’s no way to do it this way. The selector
.elemento > id
means selecting an item by class.elemento
and a direct child with the tagid
, only that there is no tagid
. The sign>
means child-direct.– Sam
@Sam I imagined. It was just to illustrate. But I thought I could do something like direct in function.
– user131623