Hello to everyone, I Have a table inside 2 div's and I need to get the tables id!
How can I do this by javascript?

Since you've provided no code, its difficult to provide specific guidance to solve your issue.

However, take a look at this example, you should be able to adapt to your needs...

<!DOCTYPE html>
<html>
<body>

<table id="table1"><tr><td>Test</td></tr></table>
<button onclick="myFunction()">Find ID</button>

<script>
function myFunction(){
  var x=document.getElementsByTagName("table")[0];
  document.write(x.getAttribute("id"))
}
</script>

</body>
</html>

You can copy/paste the above code in this Online HTML Editor to see the results...

Hello JorgeM, thank you for replying to this post of mine! Your example did what I needed for my project, thank you for helping me with this issue.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.