我有以下使用jQuery的Javascript代码:
$(document).ready(function () {
$('#answer').hide(); //hiding the element
$('#questionOne').click(function () {
$('#answer').show();但是,该元素在加载时不会被隐藏。我的HTML是这样的:
<p id="answer">All requests of this nature are required to be submitted via our website www.mufoundation.org/charityrequests. Due to the volume of requests we receive, we require at least 6 weeks notice prior to your event. If your event does not fall within this timescale unfortunately, we will not be able to help.</p>我似乎无法隐藏段落答案元素。我该怎么做呢?
发布于 2014-06-08 03:47:32
创建一个css类来隐藏这些东西,而不是在onload中这样做:
HTML:
<p class="hide">zyz</p>CSS:
.hide {
display: none;
}然后,使用jquery显示以下内容:
$(document).ready(function () {
$('#questionOne').click(function () {
$('#answer').show();
});
});https://stackoverflow.com/questions/24100850
复制相似问题