admin管理员组文章数量:1394185
I have the following TR
in HTML and i using JQuery
<tr class="RowDiv" id="tempTR" runat="server" visible="false"> <td>
<div class="LabelDiv">
<div class="dfltTxtBld">
ID<span class="reqChar" runat="server" id="Span1" visible="false">
*</span>
</div>
</div>
</td>
<td>
<div class="InputDiv">
<asp:TextBox ID="TextBox1" runat="server" CssClass="txtField" MaxLength="10"></asp:TextBox>
</div>
</td>
<td>
<div id="Div1" runat="server">
</div>
</td>
</tr>
and in javascript code i called the following method to hide it
$('#<%= tempTR.ClientID %>').hide();
but always it doesn't affected even i try to make it hidden and then show it also not work .. i try to hide & show TextBox1
and it work but if i try with the row it doesn't work ... is there any way to show/hide TR
?
I have the following TR
in HTML and i using JQuery
<tr class="RowDiv" id="tempTR" runat="server" visible="false"> <td>
<div class="LabelDiv">
<div class="dfltTxtBld">
ID<span class="reqChar" runat="server" id="Span1" visible="false">
*</span>
</div>
</div>
</td>
<td>
<div class="InputDiv">
<asp:TextBox ID="TextBox1" runat="server" CssClass="txtField" MaxLength="10"></asp:TextBox>
</div>
</td>
<td>
<div id="Div1" runat="server">
</div>
</td>
</tr>
and in javascript code i called the following method to hide it
$('#<%= tempTR.ClientID %>').hide();
but always it doesn't affected even i try to make it hidden and then show it also not work .. i try to hide & show TextBox1
and it work but if i try with the row it doesn't work ... is there any way to show/hide TR
?
- is the id TempTR unique? – Marko Commented Sep 5, 2010 at 10:27
- It works: jsfiddle/3edjh – aularon Commented Sep 5, 2010 at 10:33
- I updated the code with the real case that generate prblem – Hotmoil Commented Sep 5, 2010 at 10:42
-
@Hotmoil - Is the extra
'
a posting typo? It shouldn't pile with that in there. – Nick Craver Commented Sep 5, 2010 at 10:43 - @Nick not it was mistake from me here and i fix it .. it's not the problem – Hotmoil Commented Sep 5, 2010 at 10:45
5 Answers
Reset to default 1I think you have the same problem as in this post JQuery .Show() doesn't work with server control?
If I do this onload it works
$(document).ready(function(){
$('#tempTR').hide();
});
Maybe your problem lies somewhere else?
In your example, the textbox works because it is an asp control and the table row doesn't because it is a HTML element.
Look at the actual HTML and make sure that $('#<%= tempTR.ClientID %>').hide();
resolves to $('#tempTR').hide();
in the rendered HTML.
I haven't used ASP in awhile, but I believe it will be render as $('#tempTR.ClientID')
which isn't an ID in the DOM.
I prefer, As a you just clicked on an element inside the TR you want to hide, i will use:
$('#other').click(function() {
$(this).closest("tr").hide();
});
with some effect:
$('#other').click(function() {
$(this).closest("tr").fadeOut('slow');
});
remember to put that code in your onready function
$(document).ready(function($) {
// Code using $ as usual goes here.
});
This does not work with a table in Jquery or javascript. You have to reference a table by class or some other id. Using element ID does not work with tables.
本文标签: javascriptWhy i can39t showhide Html TR using jqueryStack Overflow
版权声明:本文标题:javascript - Why i can't showhide Html TR using jquery? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744694797a2620210.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论