javascript - can I pass dynamic id to document.getElementById(""); -


i have 2 id li element

  1. listitem1

  2. listitem2

in javascript can pass these 2 id dynamically document.getelementbyid("");

getelementbyid() method other, , therefore might provide variable containing string argument.

var identifier = "listitem1"; document.getelementbyid(identifier); 

but might consider using classes instead of ids if want address multiple instances...


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

Qt QGraphicsScene is not accessable from QGraphicsView (on Qt 5.6.1) -

What is happening when Matlab is starting a "parallel pool"? -