我有一個帶有日曆和一堆「Today in Weather History」信息的html文件。我想隱藏所有天氣歷史,直到有人點擊日曆上的特定日期,然後我只想揭示當天的歷史。如何使用jquery只顯示隱藏文本片段
每日天氣信息是隱藏的,但它不會顯示日曆日期被點擊的特定日期。我假設我正在談論這一切都是錯誤的。更好的方法來讚賞它將不勝感激。
日曆天鏈接:
<td align="right"><a id="c0408" href="#"> 8</a></td>
天氣歷史:
<div id="allhistory">
<div id="hc0408" style="display:none">
<ul>
<li class="dateheader">April 8, 2007</li>
<li>The Savannah Airport drops to 28 degrees, its lowest April
temperature.</li>
<li class="dateheader">April 8, 2007</li>
<li>Summerville has their coldest April temperature, when the mercury
falls to 27 degrees.</li>
</ul>
</div>
<div id="hc0409" style="display:none">
<ul>
<li class="dateheader">April 9, 2011</li>
<li>Severe thunderstorms impact Berkeley County in South Carolina,
with hail as large as tennis balls (2.5 inches) and winds as
high as 64 mph.</li>
</ul> <!-- 0409 -->
</div>
</div> <!-- all history div -->
jQuery代碼:
<script>
$(document).ready(function() {
$('#calendar a').click(function() {
var dateid = $(this).attr('id');
var selection = "div#h"+dateid;
$("selection").show();
})
});
</script>
「P#H」< - 你的意思是DIV#H + – Bill 2013-04-09 17:08:54
是的。我的意思是div#h – Jaystew 2013-04-09 17:50:33