Home » Javascript » Access dynamic id in js

Access dynamic id in js

Posted by: admin June 30, 2018 Leave a comment

Questions:

In html i have a div

<div class="row"  id='textdrag{{$index}}'>

I need to use the id to display context menu based on id,like.

$("#textdrag2").contextmenu(function (event) {  
    setcontextposition("text");
});

But for some reason the context menu is not displayed.

Its works just fine when i just use id=”textdrag” without the $index

Answers: