I removed some of the server-side code but this is it. thanks <script type="text/javascript"> $(document).ready(function() { $("#chkIncludeRetired").click(function() { $('#table1 .RelStatus').each(function() { var RelStatusValue = $(this).text(); if (RelStatusValue == 'Retired') { $(this).parents("div").toggle(); } }) }); }); </script>
<div id="directors"> <asp:CheckBox ID="chkIncludeRetired" runat="server" Checked="true" / ><i>Show Retired</i><br /> <div id="<%# Eval("id_individual") %>" class="IndividualDirectors"> (<span class="RelStatus" id="RelStatus"><asp:Label ID="lblRelStatus" Text='<%# Eval("RelStatus") %>' Runat="Server"/></ span>)<br /> </div> </div> On Jul 23, 11:46 am, Liam Potter <radioactiv...@gmail.com> wrote: > I'll need to see your html to see why, but I suspect it's because you > targeted a specific id #table1.RelStatus. > > > > evanbu...@gmail.com wrote: > > Very cool. This is what I have now but it only hides the first div > > containing the RelStatus value = 'Retired' > > > <script type="text/javascript"> > > $(document).ready(function() { > > $("#chkIncludeRetired").click(function() { > > $('#table1.RelStatus').each(function() { > > var RelStatusValue = $(this).text(); > > if (RelStatusValue == 'Retired') { > > $(this).parents("div").toggle(); > > } > > }) > > }); > > }); > > </script> > > > On Jul 23, 10:47 am, Liam Potter <radioactiv...@gmail.com> wrote: > > >> $("span a").click(function(){ > >> var checkValue = $(this).parents("div").attr("value"); > > >> if (checkValue == 'Retired'){ > >> $(this).parents("div").toggle(); > >> } > >> return false; > > >> }); > > >> You will see the parents function, this allows you to traverse up the dom. > > >> evanbu...@gmail.com wrote: > > >>> Right, but how do I associate the span tag which contains the value = > >>> 'Retired' with the div that contains it? In other words, I need to > >>> toggle the contents of the entire div and not just the span tag. > >>> Thanks. > > >>> On Jul 23, 7:41 am, Liam Potter <radioactiv...@gmail.com> wrote: > > >>>> use an if statement, "if value == retired, do this" > > >>>> evanbu...@gmail.com wrote: > > >>>>> Hi > > >>>>> I'm not sure how to approach this. I want to toggle each div with a > >>>>> checkbox or hyperlink which shows/hides every div where the RelStatus > >>>>> value = 'retired'. I'm able to see the value of each RelStatus value > >>>>> using the code below. The id of each div and the RelStatus value of > >>>>> each span is set server-side. Thanks > > >>>>> <script type="text/javascript"> > >>>>> $(document).ready(function() { > >>>>> $('#table1 .RelStatus').each(function() { > >>>>> alert($(this).text()); > >>>>> }); > >>>>> }); > >>>>> </script> > > >>>>> <div id="<%# Eval("id_individual") %>" class="IndividualDirectors"> > >>>>> <span class="RelStatus" id="RelStatus"><asp:Label > >>>>> ID="lblRelStatus" Text='<%# Eval("RelStatus") %>' Runat="Server"/></ > >>>>> span><br /> > >>>>> </div>- Hide quoted text - > > >>>> - Show quoted text -- Hide quoted text - > > >> - Show quoted text -- Hide quoted text - > > - Show quoted text -