0

I have a webpage that has tabs, for each tab in have some input elements within a div, I when the user clicks button I want Javascript to print out the value of all the input elements within that div.

I want the function to be generic rather than hardcoding the names of the particular fields per tab cannot use getElementsByClassName() or getElementsByName() since the elements have different names and classes.

If I give the div a name can I get all the input elements within that div somehow ?

Paul Taylor
  • 13,411
  • 42
  • 184
  • 351
  • 2
    [`getElementsByTagName`](https://developer.mozilla.org/en-US/docs/Web/API/Element/getElementsByTagName) ? – Kos Jan 21 '18 at 20:34
  • @Kos thankyou didnt know about that, seems todo the trick make it an answer and i will mark it correct. – Paul Taylor Jan 21 '18 at 20:36
  • It took me 5 seconds to find a similar question on StackOverflow: https://www.google.com/search?q=how+to+get+all+input+in+div+javascript . You really should spend some time to search before asking. – trincot Jan 21 '18 at 20:40

0 Answers0