为表中的每个td添加css [英] Adding css for each td inside the table
本文介绍了为表中的每个td添加css的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下的HTML。现在我尝试将css('display','none')添加到第三个
,用于表id'customerIdtest'的每一行,使用jquery im无法到达我的任务。 。您的帮助将受到高度赞赏。< div class ='lbd'id ='customerId'>
|
解决方案
( '#customerIdtest')。孩子( 'listrow ')。每个(函数(指数,值){
(值)。儿童(' TD')[2机] .className = 'DN';
});
< / script>
这样做 -
< table id = customerIdtest >
< tbody >
< tr class = listrow >
< td > < / td >
< td > < / td >
< < span class =code-leadattribute> td class = 隐藏 > < / td >
< / tr >
< tr class = listrow >
< td > < / td >
< td > < / td >
< td class = toHide > < / td >
< / tr >
< / tbody >
< / table >
和脚本为 -
< script type = 文本/ JavaScript的跨度>>
Hi i m having the below html. Now i m trying to add the css('display','none') to the third
for each row of the table id 'customerIdtest' using jquery im unable to reach my task.. Your help wil highly appreciated.<div class='lbd' id = 'customerId'> <table> <tbody> <tr class = 'listrow'> </tr> <tr class = 'listrow'> </tr> <tr class = 'listrow'> </tr> </tbody> </table> <div id='customerId2'> </div> <table id = 'customerIdtest'> <tbody> <tr class = 'listrow'> <td ></td> <td ></td> <td ></td> </tr> <tr class ='listrow'> <td ></td> <td ></td> <td ></td> </tr> </tbody> </table> <div id = customerId3> </div> </div> <script> $('#customerIdtest').children('.listrow').each(function(index,value){ $(value).children('td')[2].className='DN'; }); </script> |
解决方案
('#customerIdtest').children('.listrow').each(function(index,value){
(value).children('td')[2].className='DN'; }); </script>
Do it like this -
<table id="customerIdtest"> <tbody> <tr class="listrow"> <td></td> <td></td> <td class="toHide"></td> </tr> <tr class="listrow"> <td></td> <td></td> <td class="toHide"></td> </tr> </tbody> </table>
and script as -
<script type="text/javascript">
这篇关于为表中的每个td添加css的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文