0

My HTML code:

<div class="span-6">
    <p>
        <table id="symptomTable" class="symptomsTable hidden"><th>Selected Symptoms:</th><tr></tr></table>
    </p>
</div>

My CSS:

.hidden
{
display : none;
}

And lastly my 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");
            }
        });

My entire script works perfectly fine, EXCEPT for that final command

$('#symptomTable').removeClass("hidden");

that does not execute at all. I check the console in firebug and no errors are coming up. Can anyone help me find a way to fix this? I tried using show() too, it doesn't work either. Thank you for your time.

7
  • As Dhaval said, no need for a separate class. Just use the .show() and .hide() methods. Commented Jul 3, 2014 at 15:56
  • " I tried using show() too, it doesn't work either. " Commented Jul 3, 2014 at 15:57
  • @DhavalMarthak and entropic, OP says he/she has tried the show method Commented Jul 3, 2014 at 15:57
  • The table structure is invalid <table><th></th><tr></tr></table> Commented Jul 3, 2014 at 15:57
  • $('#symptomTable tbody').append( ...You have no tbody. How then is this code working? Commented Jul 3, 2014 at 15:59

1 Answer 1

3

Please make sure you do not have more than one elements with same id. A workaround would be

 $('#symptomTable .hidden').removeClass("hidden");
Sign up to request clarification or add additional context in comments.

3 Comments

This is a comment not an answer - there is nothing in the code given that suggests this would fix the problem.
I have provided a workaround also. That is the reason I posted as an answer.
That worked thanks, but I don't have another element with that id, 100% sure, I opened the code and did a search for it. Thanks anywaay :)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.