开发者

hide all td's with same id with jquery

开发者 https://www.devze.com 2023-02-21 18:33 出处:网络
<td id=\"valhisprofitVal\"><%= Math.Round(profit, 5) 开发者_运维百科%>%</td>
<td id="valhisprofitVal"><%= Math.Round(profit, 5) 开发者_运维百科%>%</td>

These rows are added dynamically, so there can be multiple rows with the same Id.

How do I hide all of them using Jquery?


You can't. Only one element can have its own ID, you can't share the same ID among multiple elements. And because of that, if you try to use JavaScript to find elements with the same ID, you'll only obtain the first of those elements.

Use a class instead:

<td class="valhisprofitVal"><%= Math.Round(profit, 5) %>%</td>

Then in jQuery, select the class:

$('.valhisprofitVal').hide();
0

精彩评论

暂无评论...
验证码 换一张
取 消