javascript - Java Script to find tag value with out ID, Tag Name -
i want value of 2nd <td>
<tr> <td>devaraj</td> <td>shiva</td> </tr> result expected : 'shiva'
how can search 1st <td> tag value , take value of 2nd <td> tag value?
thanks
you use document.queryselector() which:
returns first element within document (using depth-first pre-order traversal of document's nodes) matches specified group of selectors.
so target 2nd td:
document.queryselector('table td:nth-child(2)') see jsfiddle or following snippet
alert(document.queryselector('table td:nth-child(2)').innerhtml) <table> <tr> <td>devaraj</td> <td>shiva</td> </tr> <table>