Having trouble with the jQuery removeClass method?

Here is the HTML code I am working with:

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

This is my CSS code:

.hidden
{
display : none;
}

Now onto 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 a new symptom using javascript
                var newSymptom = 
                {
                    symptomCode: $('#symptomToBeSearchedCode').val(),
                    dateSymptomFirstSeen: $('#dateSymptomSeen').val(),
                    symptomTitle: $('#symptomToBeSearchedTitle').val()
                };
                //create a new object for symptom code
                symptomCodesQueryString = symptomCodesQueryString+"&symptomCode[]="+newSymptom.symptomCode;
                //pass the new symptom into the symptomsList array
                symptomsList.push(newSymptom);
                //increase the counter
                counter++;
                //empty input fields
                $('#symptomToBeSearchedCode').val("");
                $('#symptomToBeSearchedTitle').val("");
                //append the new symptom to the symptoms table
                $('#symptomTable tbody').append('<tr class="child"><td>'+newSymptom.symptomTitle+'</td></tr>');
                $('#symptomTable').removeClass("hidden");
            }
        });

Everything in my script works correctly except for this final command

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

It does not seem to execute at all. I have checked the console in firebug and there are no errors showing up. Can anyone provide assistance on how to fix this issue? I have also tried using show() but that did not work either. Thank you for your help.

Answer №1

It is important to ensure that there are no duplicate elements with the same id. One solution could be

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

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Getting the Pesky JQuery Switcher to Actually Function

I am currently learning Jquery effects to enhance the interactivity of my websites. I have set up a practice page with the following structure: <article><a class="front-fire" href="1"></a></article> <article><a class="fron ...

Ways to update the background shade of tr td elements inside a table

I'm having trouble changing the background color of td elements within my table. The browser keeps giving me an error message that says "Cannot read property 'children' of undefined". Despite this, my JavaScript can still navigate through al ...

Setting the column width and border-top in Highcharts

Hey there, I'm facing an issue with my highcharts diagram. 1) Can anyone help me adjust the column width to match the width of the month area? (I've tried changing "width" in CSS but it's not working) 2) Also, how can I remove all borders ...

The content box is not aligning properly with the content inside, causing it to vanish instead of overflowing with

There seems to be an issue with the content boxes on one of my pages. They all use the same CSS, but for some reason, there is a scroll bar in one of the content boxes and the footer doesn't align properly. The problem arises when I add overflow:auto ...

How can we consolidate an excess of menu items into a condensed, collapsed menu?

I have a navigation bar displaying category items, but if the menu items exceed the navbar width, how can I condense them into a drop-down menu using Bootstrap 3.0? Currently, my navbar only shows 10 items due to limited space. However, I have more items ...

occupying half of the screen

Having trouble displaying two videos in an ionic grid. My goal is to have both videos take up the entire screen, with each occupying 50% height and 100% width. However, when I try to achieve this, the ion-row only takes up 50% of the screen and the video i ...

How do I repeatedly invoke a function in JQuery that accepts two different arguments each time?

I have a collection of folders, each containing various images. The number of pictures in each folder ranges from 8 to 200. Folders are numbered from 1 to 20 and the images within them are also labeled numerically. My goal is to aggregate all these images ...

Using CSS to align the position of a div with the last word position of an h4 element

Trying to figure out how to position a div at the end of an h4 text element has been challenging. When the h4 text is on a single line, it's easy to place the div correctly. However, things get complicated when the text spans multiple lines. In that c ...

Can elements be prevented from resizing in relation to another element without using position:absolute?

Is there a way to prevent elements in a <div> from moving when an adjacent element is resized, without using position:absolute? Any help would be greatly appreciated. Thank you in advance! ...

Description positioned along the edge of the image

Is it achievable in Bootstrap 4.1 to have the caption aligned with the image margin as displayed in the image below? Illustration of aligning caption with image Following the sample at getbootstrap.com, there exists a discrepancy between the caption and ...

iOS application receives a 430 forbidden error when handling Ajax response in Cordova

I've been working on creating a SAPUI5 Application and encountered an issue when trying to run it on the cordova iOS platform. I keep receiving a 403 forbidden response from the server when sending a jQuery ajax request. Interestingly, the service wor ...

Creating dynamic height based on width using JavaScript

I'm trying to make a rectangle responsive based on the width of the window. This is my current logic: aspectRatio = 16 / 9 win = { width: window.innerWidth, height: window.innerHeight, } get browser() { const width = this.win.width - 250 ...

Having difficulty modifying the width of the BODY element using CSS

For my webpage, I want the body to have a silver background that fills only 75% of the page. This means that only 75% of the page will be painted silver, while the remaining part will be left unused and painted according to the browser's defaults. The ...

Tips for minimizing the padding/space between dynamically generated div elements using html and css

Currently, I have 4 dropdown menus where I can choose various options related to health procedures: Area, specialty, group, and subgroup. Whenever I select a subgroup, it dynamically displays the procedures on the page. However, the issue I am facing is th ...

modifying the width of the primary container following the display or concealment of an alternate container

I am working on a main div that contains two separate divs for main content and sidebar content. The sidebar content can be hidden or shown by clicking a link. When the sidebar is hidden, I want the content div to occupy the entire space within the conta ...

JavaScript overlay that does not interact with HTML elements directly

Currently, I am facing the challenge of implementing a javascript overlay upon page load without direct access to the html code. My only options are to upload .js and .css files. I have extensively searched for solutions, but as someone with limited exper ...

Redirecting to a blank homepage using PHP

Having trouble with this code. After logging in, I'm not redirected to the home page, but instead, I stay on the login page. I want users to be redirected to (http://localhost/trial/index.php#Home) once successfully logged in. How can I fix this? < ...

Deciding Between Two Columns or One Column for Your JQuery Accordion

I am currently working on customizing an Accordion that is too large in height for my liking. My goal is to convert the single column layout into a two-column display, side by side. Having multiple items in one column results in excessive height, hence t ...

Guide on sending MySQL query results as JSON data using Ajax

I'm having trouble figuring out how to pass the results of a MySQL query into an HTML page using AJAX and JSON. I have the following code in ajax2.php: $statement = $pdo->prepare("SELECT * FROM posts WHERE subid IN (:key2) AND Poscode=:postcode2") ...

Is it possible to override tags on a Bootstrap landing page?

Seeking assistance with a body tag override issue I am currently facing. Here is the webpage in question: I am attempting to implement a responsive full-screen background image on this page (homepage only) by utilizing the full.css file linked to the page ...