【发布时间】:2012-09-09 21:09:13
【问题描述】:
我有一个 div 需要隐藏到 10 月 12 日,然后从 10 月 13 日开始显示。该站点是用 C# .NET 构建的,因此我可以在 HTML 页面的代码隐藏中添加一个 if 语句。不确定这是否可行,或者我是否需要一个 jQuery 解决方案(我对此一无所知)。任何帮助将不胜感激。
这是 HTML 中的代码:
<p style="bold">SHOW THROUGH 10/12!!!<p>
<p>Every day from now until Metastatic Breast Cancer Awareness Day (Oct. 13), a new video will be featured. Please check-in every day to hear a new story and come back on Oct. 13 to see the new, complete video wall.</p>
<div id="mbcRadioList">
<p style="bold">BUILD BUT HIDE UNTIL 10/13!!!<p>
<p><strong>Want to learn more?</strong> Select a video topic to better understand the varied experiences of people living with MBC and their family and friends.</p>
<div class="checkBoxesColumn">
<label><input name="videoWallRadio" type="radio" id="" value="" />View All</label>
<label><input name="videoWallRadio" type="radio" id="" value="" checked />My MBC Journey</label>
<label><input name="videoWallRadio" type="radio" id="" value="" />Challenges</label>
<label><input name="videoWallRadio" type="radio" id="" value="" />Positive Outlooks & Advice</label>
<label><input name="videoWallRadio" type="radio" id="" value="" />Giving Thanks</label>
<label><input name="videoWallRadio" type="radio" id="" value="" />Family / Friend Perspective</label>
</div>
</div>
我在列表周围添加了<div id="mbcRadioList"> 以获得在代码隐藏中控制的句柄,如果有办法做到这一点。如果它是 jQuery 解决方案,我可以将其删除。
提前致谢!
【问题讨论】:
-
我会尝试将 div 标记为隐藏,然后检查您的页面加载事件是否应该取消隐藏
-
如果您在元素上添加了 id 和
runat="server",您可以在代码隐藏中引用它并根据您的条件将 Visible 设置为 false。 -
我不建议这是客户端的事情。因为用户可以将他的系统日期更改为未来的任何日期
-
不要忘记考虑时区。隐藏的 div 是否应该同时为所有用户显示,无论位置如何(午夜在某个任意位置)?还是应该出现在每个用户当地时间的午夜?
-
使这成为客户端问题的另一个危险:时区。您必须在 GMT 时间完成所有数学运算。