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 8986365
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T21:31:57+00:00 2026-06-15T21:31:57+00:00

$(#btnCon).click(function() { $(‘#con’).slideToggle(‘slow’); $(‘.tgg:not(#con)’).hide(); }); When I place this code in the head of

  • 0
$("#btnCon").click(function() {
    $('#con').slideToggle('slow');
    $('.tgg:not(#con)').hide(); 
});

When I place this code in the head of html – it doesn’t work.
In the body – it works.
In a separate file – it doesn’t work.
Where is the secret ?

  • 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-06-15T21:31:58+00:00Added an answer on June 15, 2026 at 9:31 pm

    To make it work in head do this :

    $(function(){
      $("#btnCon").click(function() {
        $('#con').slideToggle('slow');
        $('.tgg:not(#con)').hide(); 
      });
    });
    

    The problem was that you were looking for the element with id btnCon before it was ready. The usual solution is to embed the code in this callback that jQuery calls when the DOM is ready.

    But note that even while using $(function(){ ... }); is always recommended, the best practice is generally to put your code either

    • in a separate javascript file
    • in a script element at the end of the body
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is the functionality simply when click btnGo timer will stop and get it's
I have a form with two buttons: btn_oldFile and btn_newFile. Both buttons, on click
<div class=btns id=btnHome>HOME</div> <div class=btns id=btnCon>CONTACT</div> <div style=clear:both;></div> <div id=gall></div> CSS .btns{ float:left; padding:
I have just started with JQuery and I need to change the css class
I am trying to make a modular application in delphi2010 using BPL. Problem is
I have a DataGridView bound to a list of business objects: Dim template As
I am trying to pull data from a Database using C#.net and use a
i have in php a table with some rows. Each row contains a dataset
I am using Jquery to dynamically populate the table element. My table will have
I'm a bit stuck with a problem. I feel like the solution should be

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.