admin管理员组文章数量:1406020
I have a table structure as given below:
<table>
<tr>
<td id="td1"> </td>
<td id="td2"> </td>
<td id="td3"> </td>
<td id="td4"> </td>
</tr>
</table>
I am checking some condition like:
if(a==2 || check == true)
I want to hide the "td3" if any one condition satisfies.
My code is in C#.
I have already tried
document.getelementbyId("td3").style("display"= "none"),
document.getelementbyId("td3").display.hide();
td3.Attributes.add("style", "display:none")
I have a table structure as given below:
<table>
<tr>
<td id="td1"> </td>
<td id="td2"> </td>
<td id="td3"> </td>
<td id="td4"> </td>
</tr>
</table>
I am checking some condition like:
if(a==2 || check == true)
I want to hide the "td3" if any one condition satisfies.
My code is in C#.
I have already tried
document.getelementbyId("td3").style("display"= "none"),
document.getelementbyId("td3").display.hide();
td3.Attributes.add("style", "display:none")
Share
Improve this question
edited Aug 29, 2018 at 17:29
Louys Patrice Bessette
33.9k7 gold badges40 silver badges66 bronze badges
asked Aug 29, 2018 at 16:23
Sumit RajguruSumit Rajguru
191 silver badge7 bronze badges
4
-
2
What does this have to do with
C#
,asp
orvb
? – maccettura Commented Aug 29, 2018 at 16:26 - 4 Need solution as soon as possible - Stack Overflow is not a free code-writing service. – Derek 朕會功夫 Commented Aug 29, 2018 at 16:26
-
1
My code is in C#.
yet all I see is HTML and JavaScript. What code is in c#? – Camilo Terevinto Commented Aug 29, 2018 at 16:27 - before adding immature ment, develop a holistic thinking capability. thanx for ment though! – Sumit Rajguru Commented Aug 30, 2018 at 17:04
2 Answers
Reset to default 5Your three JavaScript examples aren't valid JavaScript. I remend reading the JavaScript docs a bit more in depth!
You can use the code below to hide the td
.
document.getElementById("td3").style.display = "none";
<table>
<tr>
<td id="td1">TD1</td>
<td id="td2">TD2</td>
<td id="td3">TD3</td>
<td id="td4">TD4</td>
</tr>
</table>
You can simply use jQuery
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis./ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$('#td3').hide()
});
</script>
</head>
<body>
<table>
<tr>
<td id="td1">TD1</td>
<td id="td2">TD2</td>
<td id="td3">TD3</td>
<td id="td4">TD4</td>
</tr>
</table>
</body>
</html>
本文标签: javascriptHiding a lttdgt depending on the ConditionStack Overflow
版权声明:本文标题:javascript - Hiding a <td> depending on the Condition - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744960571a2634629.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论