繁体   English   中英

如何将属性/ styles 添加到 angular 中父元素内的子节点

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

我有一张桌子

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

我想在<tbody>中的<tr>中添加一个属性,而不是<thead>

添加此行后(<HTMLElement>document.querySelector('tr')).setAttribute("draggable", "true");

桌子看起来像

<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>

如何在<tobdy>中将draggable=true添加到<tr> >

这会帮助你

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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