我的HTML代码:
<div class="span-6">
<p>
<table id="symptomTable" class="symptomsTable hidden"><th>Selected Symptoms:</th><tr></tr></table>
</p>
</div>
我的CSS:
.hidden
{
display : none;
}
最后我的javascript:
$('#addSymptom').click(function()
{
if($('#symptomToBeSearchedTitle').val()=="")
{
alert('You need to select a symptom.');
}
else if($('#dateSymptomSeen').val()=="")
{
alert('You need to select the date the symptom was first seen on.');
}
else
{
//create new symptom in javascript
var newSymptom =
{
symptomCode: $('#symptomToBeSearchedCode').val(),
dateSymptomFirstSeen: $('#dateSymptomSeen').val(),
symptomTitle: $('#symptomToBeSearchedTitle').val()
};
//create new object for symptom code
symptomCodesQueryString = symptomCodesQueryString+"&symptomCode[]="+newSymptom.symptomCode;
//pass new symptom into symptomsList array
symptomsList.push(newSymptom);
//increase counter
counter++;
//empty input
$('#symptomToBeSearchedCode').val("");
$('#symptomToBeSearchedTitle').val("");
//append symptoms table
$('#symptomTable tbody').append('<tr class="child"><td>'+newSymptom.symptomTitle+'</td></tr>');
$('#symptomTable').removeClass("hidden");
}
});
我的整个脚本完全正常,除了最后的命令
$('#symptomTable').removeClass("hidden");
根本不执行。我在firebug中检查控制台,没有错误出现。任何人都可以帮我找到解决这个问题的方法吗?我也试过使用show(),它也没有用。谢谢你的时间。
答案 0 :(得分:1)
请确保您没有多个ID相同的元素。解决方法是
$('#symptomTable .hidden').removeClass("hidden");