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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:38:30+00:00 2026-05-27T13:38:30+00:00

I am trying to fade in div elements but for some reason every time

  • 0

I am trying to fade in div elements but for some reason every time I preview my script code it just displays it and doesn’t run it

my script code is –

 <script>
$("#t<?php echo $pNumber ?>").click(function() {
$("#b.<?php echo $pNumber ?>").fadeToggle("slow", "linear");
});
</script>

the PHP variable is used for changing div id’s would this be causing a problem?

Thanks,

UPDATE –

example html this is for one of the div’s (the id is incremented)

  <div id="t1">Carl Froch 'fitter than ever' for Andre Ward Showtime Super Six       fight</div>
  <div id="b1"><p>Carl Froch gives Andre Ward seven years but no encouragement to      believe their fight  on Saturday night is a war of the ages.</p><p>The 34-year-old WBC    champion from Nottingham rarely strays far from the 12-stone limit of his division and is     hard o...<p><a href=http://www.guardian.co.uk/sport/2011/dec/14/carl-froch-andre-  ward-showtime-super-six>Click here for full article</a></p>   </div  <script>
  $("#t1").click(function() {
  $("#b1").fadeToggle("slow", "linear");
  });
 </script>

JB

  • 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-27T13:38:31+00:00Added an answer on May 27, 2026 at 1:38 pm

    In your element selectors:

    • You’re including the $pNumber as part of the t‘s id for the click event
    • You’re including the $pNumber as part of the b‘s class for the fadeToggle

    To fix this, do one of these:

    • Add a dot to the #t selector, to make it select based on class
    • Remove the dot from the #b selector, to make it select based on id

    See this fiddle before removing the .:

    $("#t1").click(function() {
        $("#b.1").fadeToggle("slow", "linear");
    });
    

    See this fixed fiddle:

    $("#t1").click(function() {
        $("#b1").fadeToggle("slow", "linear");
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to fade out a div on a click but also change some
I'm trying to fade all elements on a webpage except for one div. I've
I am trying to get my div to fade out using pure CSS. But
I have been trying to make a div fade in evey 30sec and out
So, I'm trying to fade in a transparent div, kinda like hulu does when
I am trying to use jQuery to fade out a div, using the fadeOut
im trying to make a div fade out and then have a second div
I'm trying to get div id from clicked img alt value and fade in
I am trying to create some jquery styled hover fade in/out thumbnails. I've managed
I'm trying to make a div fade out with jquery after the form validates

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.