Sorry if this question seems noob or doesnt make sense, i am very new to JS.
i have a web page like below –
<td class="main" data="chair">Chair</td>
<td class="main" data="table">Table</td>
<td class="main" data="desk">Desk</td>
I know how to select document by its ID or class name but here as you can see class name is same for all, how can i select value of Table?
I had tried using document.querySelectorAll and implemented foreach on it too but failed.
Can you let me know how it can be done.
2
Answers
Use an attribute selector:
https://developer.mozilla.org/en-US/docs/Web/CSS/Attribute_selectors
Can you try this code ?