What could be the reason that the accordion is failing to expand or collapse when clicked?

I am facing an issue where the div is not expanding or collapsing upon clicking the + sign. I have tried removing unnecessary scripts but it still doesn't work. Additionally, there is an error in the console:

Uncaught TypeError: $(...).slideReveal is not a function

            <div class="card">
                <div class="card-header" id="headingOne">
                    <div class="row" style="margin-top: -15px; height:52px;">

                        <div class="col-6 pt-3">
                            <h5 class="font-mobile">Planning Engineer</h5>
                        </div>

                        <div class="col-6 pt-3" style="height:auto;">
                            <h5 class="mb-2 text-right">
                                <button class="btn btn-link collapsed" type="button" data-toggle="collapse" data-target="#collapseOne" aria-expanded="false" aria-controls="collapseOne">
                                    <h5>+</h5>
                                </button>
                            </h5>
                        </div>
                    </div>

                    <div id="collapseOne" class="collapse" aria-labelledby="headingOne" data-parent="#accordion">
                        <div class="card-body" style="height:auto;">
                            <h5 class="overflow-hidden mt-xs-2">Job Description:</h5>
                            <ul class="text-justify ul-xs">
                               // job description details here ...
                            </ul>
                            <h5> As our ideal candidate you will have:</h5>
                            <ul class="text-justify ul-xs">
                              // candidate requirements listed here ...
                            </ul>

                        </div>
                    </div>
                </div>
            </div>

Here's the source code of head being rendered.


  // main stylesheet and js imports

Updated: Tried to implement a new sequence for the script loading, but the issue persists.


    // updated script import sequence

Answer №1

The unnecessary data-parent="#accordion" attribute was mistakenly added to the

<div id="collapseOne" class="collapse" aria-labelledby="headingOne">
line. I have rectified this in the following code snippet by eliminating that attribute. Hopefully, this correction resolves the issue for you. Thank you.

<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet"/>
<div class="card">
    <div class="card-header" id="headingOne">
        <div class="row" style="margin-top: -15px; height:52px;">

            <div class="col-6 pt-3">
                <h5 class="font-mobile">Planning Engineer</h5>
            </div>

            <div class="col-6 pt-3" style="height:auto;">
                <h5 class="mb-2 text-right">
                    <button class="btn btn-link collapsed" type="button" data-toggle="collapse" data-target="#collapseOne" aria-expanded="false" aria-controls="collapseOne">
                        <h5>+</h5>
                    </button>
                </h5>
            </div>
        </div>

        <div id="collapseOne" class="collapse" aria-labelledby="headingOne">
            <div class="card-body" style="height:auto;">
                <h5 class="overflow-hidden mt-xs-2">Job Description:</h5>
                <ul class="text-justify ul-xs">
                    <li>Prepare and update project schedule based on the contract.</li>
                    <li>Set work program and target milestones for each phase based on the project plan</li>
                    <li>Monitor critical activities based on the project schedule and advise project management.</li>
                    <li>Prepares and submit updated work program and cash flow curve showing actual progress and identify areas of weakness and establishes means and methods for recovery, if any, as well as new critical activities.</li>
                    <li>Monitor day to day work progress and prepare the weekly and monthly program and report.</li>
                    <li>Maintain and record update of work progress obtained from Project Manager.</li>
                    <li>Prepares monthly report reflecting work progress summary.</li>
                    <li>Provide process support to the other engineering disciplines</li>
                    <li>Provide specialist technical input into team project work</li>
                    <li>Develop or bring forward, as appropriate, industry best practices and new technologies.</li>
                    <li>Prepare and review project proposals, studies, and technical reports</li>
                    <li>Travel to sites as needed.</li>
                </ul>
                <h5> As our ideal candidate you will have:</h5>
                <ul class="text-justify ul-xs">
                    <li>Bachelor or higher degree in Engineering</li>
                    <li>At least 7-8 years of experience in oil and gas sector.</li>
                    <li>Strong command on MS Project, MS excel and Primavera P6</li>
                    <li>Ability to communicate complex ideas effectively – both verbally and in writing – in English.</li>
                    <li>Outstanding record of academic achievement.</li>
                    <li>Ability to work effectively with people at all levels in an organization.</li>
                    <li>Excellent analytical and quantitative problem-solving skills.</li>
                    <li>Knowledge of International and Local applicable environmental laws and regulations.</li>
                </ul>

            </div>
        </div>
    </div>
</div>

<!-- Optional JavaScript -->
    <!-- jQuery first, then Popper.js, then Bootstrap JS -->
    <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>

Answer №2

If you're encountering issues with executing a method before the DOM is ready for manipulation, it may be due to all your script tags being placed within the head tag rather than after the body content. To resolve this, consider wrapping your function call in the following format:

$(function() {
  // Handler for .ready() called.
})

For more information, you can refer to: https://api.jquery.com/ready/

On another note, optimizing the page by bundling resources can significantly improve the load time for users, even though it's unrelated to the current issue.

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

Processing of an array received via AJAX and passed to a PHP script, inside a separate function in a different file

I have a JavaScript array that I am sending via AJAX to a PHP file named aux.php. What I want is for this array to be visible and manipulable within a function inside a class in another PHP file called payments.php. I've provided all the code so they ...

Ways to show dropdown menu link exclusively on mobile browsers and not on desktop browsers

<li class="megamenu-content"> <div class="megamenu-content-wrapper clearfix"> <ul class="col-lg-3 col-sm-3 col-md-3 "> <li class="cat-header">DISPLAY MEMBERS</li> ...

Unlock the Power of Angular: Leveraging ViewEncapsulation.Native to Access HTML Elements

I am encountering an issue where I am receiving an error when trying to access an HTML element by ID. The problem arises when I attempt to access the classList upon a user clicking a button to apply a different style class to the element. The class list an ...

javascript strange behavior

I am facing an issue with my code that is attempting to display images based on their height. Strangely, the code seems to work fine when I test it with 2 images, but fails when trying with 3 or more. Check out the site: Upon clicking a menu button, the ...

Error encountered: Unable to assign onClick property to null object

Hey everyone, I'm running into an issue with my JavaScript. It keeps throwing a TypeError: Cannot set properties of null (setting 'onclick') at SignUp.js:4:43 <HTML> <body> <div class="input-box"> <span class="deta ...

Generating values in a loop - mastering the art of creating data points

My goal is to create a variable within a loop: box-shadow: 835px 1456px #FFF, 1272px 796px #FFF, 574px 1357px #FFFand so on... The concept is simple: box-shadow: x1 y1 #fff, x2 y2 #fff, x3 y3 #fff, x4 y4 #fff ... xn yn #fff. I attempted to achieve this ...

"Choosing a div element using nth-child() method: a step-by-step guide

An HTML structure was provided which includes a section with an id of "main-content" and a class of "photo-grid". Inside this section are multiple div elements with a class of "col-1-4", each containing a link, paragraph, and image. <section id="main-c ...

Insert image using AJAX

I am attempting to use Ajax to dynamically add an <img> element to a div on my webpage. The image's name needs to be fetched from a database. Although I have successfully added the <img> tag to the div and set the correct source (src) att ...

Fluid active tabs are causing alignment issues with CSS triangles

I have included CSS triangles on the active tabs with fluid width on this page, but they are not aligned properly in each tab. For example, the About Us tab is correctly and centrally aligned, but the others are too far to the right. The issue lies with t ...

Enhance link with dynamic content using an AJAX call

I need help appending a picture after a link with the same URL as the link. The current AJAX code is producing the following result: <a href="images/Draadloos.png" data-lightbox="gallerij"></a> Here is an example of what I would like to achie ...

Positioning a Material UI Menu item underneath its parent element using CSS styling

I have created a Material UI dialog that features some text and an Icon with a dropdown menu option. You can check out the demo here: https://codesandbox.io/s/prod-rain-1rwhf?file=/src/App.js My goal is to properly position the Menu component so that it a ...

Troubleshooting a mapping problem with CSS elements

While building my website, I have successfully mapped the elements by ID for all alphabet letters except A. When clicking on the letter A, it does not go to the respective elements. Can anyone please help me find a solution? Visit this link for reference ...

What is the method for ensuring that the delete functionality is displayed within the same row?

In my division, there are options for names and deletion. It is displayed on my website as: 1.jpg delete The HTML code for the division is: <div id="files1" class="files"> <b class='dataname' >1.jpg</b> <span cla ...

When I press the button, a model popup will display the complete information

How can I display full information on a model popup when clicking a button? <button type="button" class="btn btn-primary btn-xs" data-toggle="modal" data-target="#myModal" > <i class="glyphicon glyphicon-zoom-in"></i> </button>< ...

Exploring the differences: Bootstrap-Vue versus Bootstrap 4

After utilizing Vuejs to develop my frontend, I am now faced with the task of styling it. In my research, I stumbled upon Bootstrap-vue. I am wondering which option would be more beneficial - using Bootstrap 4 or Bootstrap-vue. Are they essentially the s ...

Guide to adding checkbox IDs and inserting them into a textarea

Hello, my name is Prasath and I am currently learning about AJAX. I am working on a project involving seat layouts and finding it challenging to retrieve both the seat fare and seat number simultaneously. Is there anyone who can assist me in resolving this ...

Unable to supersede the current CSS styling

I have implemented the example found here in my project and now I am trying to make the table stretch to fit the entire page. To achieve this, I have added the following CSS: html, body{ height: 100%; } #gridContainer { height: 100%; } table{ ...

Can you show me a way to use jQuery to delete several href links using their IDs at once?

Currently facing a challenge with removing multiple href links that share the same ID. Here is a snippet of my code: $('.delblk').click(function(e) { e.preventDefault(); var id = $(this).attr('id').substr(7); ...

Variables are losing their way in the vast expanse of self-submitting

I have a form that needs to be submitted on the same page (index.php) and I want to capture the entered information as a JavaScript variable. <?php $loginid = $_POST[username] . $_POST[password]; ?> Here is some basic code: <script> var pass ...

``Are there any thoughts on how to troubleshoot display problems specifically on mobile

Whenever I use Safari on iOS for my web application, I encounter strange rendering issues. It's odd because the majority of the time everything functions as it should, but every now and then these bugs crop up with no discernible pattern. Examples th ...