[Solved] How can set javascript variable value as id attribute of a html element


Try this:

<html>
 <script>
 var i=0;
 function data(ele)
      {
        i++;
        ele.setAttribute("id","form"+i);
       }

   </script>
  <body>
  <a href="#x" onclick="data(this);"</a>
  </body>
  </html>

1

solved How can set javascript variable value as id attribute of a html element