Search code examples
javascriptinternet-explorermozilla

document.getElementById("xxx").name = "sample" not working in firefox but works in IE


Can somebody help on this one. I am trying to set the name of a element dynamically.


Solution

  • Try using setAttribute.

    Example:

    var element = document.getElementById("xxx");
    element.setAttribute("name", "sample");