简体   繁体   中英

How to add a property/ styles to child nodes inside a parent element in angular

I had a table

<table>
 <thead> 
  <tr> </tr>
 </thead>
 <tbody> 
  <tr> </tr> 
 </tboday>
</table>

I want to add a property to <tr> inside <tbody> not <thead>

After I add this line (<HTMLElement>document.querySelector('tr')).setAttribute("draggable", "true");

the table looks like

<table>
 <thead> 
  <tr draggable=true> </tr>
 </thead>
 <tbody> 
  <tr> </tr>  // note here there is no above mentioned property. I need to put here
 </tboday>
</table>

How can I add draggable=true to <tr> inside <tobdy>

this will help you

 document.querySelector('tbody tr').setAttribute("draggable", "true");
 <table> <thead> <tr></tr> </thead> <tbody> <tr>here </tr> </tbody> </table>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM