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 -

reflection - How to access the object-members of an object declaration in kotlin -

php - Doctrine Query Builder Error on Join: [Syntax Error] line 0, col 87: Error: Expected Literal, got 'JOIN' -