I notice that javascript have several way to set and get attribute with an element.
I am not sure is there any diffrence between them. especially, is there cross br
Javascript guarantees element["attr"] and element.attr to be the same.
setAttribute(), however, is not part of the language itself but of the DOM layer above it. There is no guarantee it's the same as a write to the attr attribute. It can do more, or even less (i.e. not even update the attr attribute of the object and require you to call getAttribute() to get the value back).
In practice, the three ways are generally equivalent. Watch out for things like this, though.