After searching the web with no answer, I really need some help about
attributes in jquery

Here's the plan:
I want to retrieve ALL the attributes from a tag for applying them to
another tag.

Problem#1: i don't know how many attributes the tag will possess.
Problem#2: i don't know what attributes will be used.

For example i will have a sample tag like that (attributes can vary) :
<table border="1" width="760" cellspacing="2" cellpadding="3" id="t">

I want to take all the attributes and apply them to another empty
<table> tag.

Using DOM manipulation without jquery, it works fine :
[code]
<html>
  <head>
    <script type="text/javascript" language="javascript">
    window.onload = function () {
        var contbl = document.getElementsByTagName('table')[0];
        table = document.createElement("table");
        for (i=0;i<contbl.attributes.length;i++){
            if (contbl.attributes[i].specified)
                table.setAttribute(contbl.attributes[i].nodeName,
contbl.attributes[i].nodeValue);
        }
        rowA = table.insertRow(0); cell = rowA.insertCell(0);
cell.innerText = "New table";
        document.body.appendChild(table);
    }
    </script>
  </head>
  <body>
      <table border="1" width="760" cellspacing="2" cellpadding="3">
          <tbody>
              <tr>
                  <td>First table</td>
              </tr>
          </tbody>
      </table>
  </body>
</html>
[/code]

But when I try to reproduce such manipulation using jquery i can't
find no solution!

I hope that one of you could give me a tip about converting this to
jquery, or maybe it's not possible ? Thanx for your help

Reply via email to