When to use setAttribute vs .attribute= in JavaScript?
Has a best-practice around using setAttribute instead of the dot (.) attribute notation been developed? E.g.: myObj.setAttribute(“className”, “nameOfClass”); myObj.setAttribute(“id”, “someID”); or myObj.className = “nameOfClass”; myObj.id = “someID”; 12 Answers 12