Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7491351
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T16:00:13+00:00 2026-05-29T16:00:13+00:00

Ok an have an accordion, but i am not using jQuery UI. This is

  • 0

Ok an have an accordion, but i am not using jQuery UI. This is my code

xHTML:

<ul>
    <h2>What are your hours?</h2>
    <li>Donec nec justo eget felis facilisis fermentum. Aliquam porttitor mauris sit amet orci. Aenean dignissim tesque felis.</li>

    <h2>What are your hours?</h2>
    <li>Donec nec justo eget felis facilisis fermentum. Aliquam porttitor mauris sit amet orci. Aenean dignissim tesque felis.</li>

    <h2>What are your hours?</h2>
    <li>Donec nec justo eget felis facilisis fermentum. Aliquam porttitor mauris sit amet orci. Aenean dignissim tesque felis.</li>

    <h2>What are your hours?</h2>
    <li>Donec nec justo eget felis facilisis fermentum. Aliquam porttitor mauris sit amet orci. Aenean dignissim tesque felis.</li>
</ul>

And jquery:

$.fn.acc = function() {

  $('li').not(':first').hide();
  $('h2:first').addClass('selected'); 
    $('h2').on('click', function() {
      $('.selected').removeClass('selected');
      $(this).addClass('selected');
      var li = $(this).next('li');
      check = (li.is(':visible')) ? li.slideUp(200) : ($('li').slideUp(200))(li.slideDown(250));
  });
};
// Call the function here
$(function() {
  $('ul').acc();
});

The code is working, but when you click on h2 tag every time you get in the console log the following message:

Uncaught TypeError: object is not a function.

Can someone tell me what is the problem, because the code is ok and works like a charm.

Here is a [link]1
Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T16:00:33+00:00Added an answer on May 29, 2026 at 4:00 pm

    Here is your code redone much simpler and with valid html
    — Updated to use selected class —
    http://jsfiddle.net/5HfBc/6/

    html:

    <ul>
        <li><h2>What are your hours?</h2>
            <p>Donec nec justo eget felis facilisis fermentum. Aliquam porttitor mauris sit amet orci. Aenean dignissim tesque felis.</p>
         </li>
         <li><h2>What are your hours?</h2>
            <p>Donec nec justo eget felis facilisis fermentum. Aliquam porttitor mauris sit amet orci. Aenean dignissim tesque felis.</p>
         </li>
         <li><h2>What are your hours?</h2>
            <p>Donec nec justo eget felis facilisis fermentum. Aliquam porttitor mauris sit amet orci. Aenean dignissim tesque felis.</p>
            </li>
    
    
        </ul>
    

    javascript:

    $.fn.acc = function() {
        $('li:first p').addClass("selected").show();
        $('li h2').click(function(e) {           
            $(this).siblings("p").slideToggle(200)
                .parent().addClass("selected")
                .siblings("li").removeClass("selected")
                .find("p").slideUp(200);
        });
    };
    
    $(function() {
      $('ul').acc();
    });
    

    css:

    ul{width:400px; margin:auto; }
    li {margin: 0px; padding: 0;  text-align: left;} 
    li p { display: none; }
    
    h2 { font-size:12px; padding:0.5em; background: #e4e4e4; margin: 0px; cursor: pointer; font-weight:bold; font-size:1.5em; line-height: 2em;  border-bottom: 1px solid #c5c5c5; border-top: 1px solid #ffffff; border-radius: 5px; box-shadow: 0px 0px 0px #cdcdcd;} 
    .selected h2 {background: #dcdcdc; color:black;}
    h2:hover {background-color:#dcdcdc;}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have tried using the accordion plugin, but it does not work, and I
where I am using Jquery UI. I have an accordion menu, which has multiple
I have a code in javascript and I am using jQuery Calculation plugin (can
This is followup question from my previous question Toggle button inside accordion using jquery
I am using the JQuery UI Accordion. We have to make our site 508
I have a simple accordion menu I've put together today using the jQuery slideDown()
I have made a simple accordion for my site using jQuery... It worked great,
I have this code that will load css/js/jst (javascript templates) using $.ajax and I'd
I have a few JavaScript files with some jQuery code. I am including this
I have to make something like an accordion, but I want it to fade

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.