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

[ad_1]

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

[ad_2]

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