繁体   English   中英

` <td> 如果`tr`的显示不为空,将计算`

[英]`<td>` will be calculated if the display of the `tr` is not none

在我的cshtml文件中,如果tr的显示不是全无,我希望计算<td>

<tr id="abc" style="display:none;height: 30px;">
<td class="titleStyle">Page:</td>

<td align="left">@Html.DropDownList(("pages"), 
(IEnumerable<SelectListItem>)ViewData["mypages"], new { onchange = "func()",
id = "page2",  style = "float:left; width: 276px;height: 20px;" })</td>

所以我尝试了类似的东西:

<script type="text/javascript">
   if ($("#abc").css("display") != "none") {

   }
</script>

但是我该如何继续呢?

任何帮助表示赞赏!

你的意思是这样的吗? 使用window.getComputedStyle (IE9 +)

HTML

<table>
    <tbody>
        <tr id="abc" style="display:none;height: 30px;">
            <td class="titleStyle">Page:</td>
        </tr>
        <tr id="abcd" style="height: 30px;">
            <td class="titleStyle">Page:</td>
        </tr>
    </tbody>
</table>

Java脚本

var trs = document.getElementsByTagName("tr"),
    length = trs.length,
    i = 0;

while (i < length) {
    if (window.getComputedStyle(trs[i]).display !== "none") {
        trs[i].children[0].firstChild.nodeValue = "Page: 1";
    }

    i += 1;
}

jsfiddle上

暂无
暂无

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

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