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