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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:22:27+00:00 2026-05-28T04:22:27+00:00

This is a very simple, probably too simple question but I’m afraid my limited

  • 0

This is a very simple, probably too simple question but I’m afraid my limited skills in jQuery require someone’s help!
Behold the shameful line of code:

onclick="javascript:  $j('#'+openc).fadeOut('normal', function({
$j('#'+openc).fadeIn('slow')});
openc=+1;
alert('The city of ' + openc + ' is located in ' + openc + '.');"

By default, openc is set to 0.

Onclick, the div with the id 0 is faded out, and I wish to have div id 1 open, then openc to b updated to 1. I added the alert for my own sake. When I press once, it seems to work. When I press it again, it still alerts 1, thus my div id 1 fades out and right back in.
I think I just need to add +1 to the fadeIn function with the onclick, so that it will always open openc+1 but..can’t seem to get the syntax right.

Thanks!

EDIT: Perhaps my question was not clear enough, I figured I would add some info. I beg you to not suggest things such as adding event-handlers, I have no clue what that even means, I am a total noob at javascript/jQuery. All I need to do is this:

onclick, fadeout the div openc (which yes, is a number) ,fadein openc +1, and update openc to its own value +1.

This is for a pagination of sorts between divs.
So say you land on div id=0, openc=0. You click on next, it should fadeout div0, fadein div1, and openc should now equal1. That way, the next time you click next, div1 fades out, and div2 appears, etc.

Hope that clarifies, thanks again!

  • 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-28T04:22:27+00:00Added an answer on May 28, 2026 at 4:22 am

    You should put this code in to an event handler, rather than use the outdated onclick HTML attribute. Try putting this in to the <head> of your page:

    <script type="text/javascript">
        $(function() {
            $j("#myElement").click(function() {
                $j('#' + openc).fadeOut('normal', function() {
                    $j('#' + openc).fadeIn('slow')
                });
    
                openc += 1;
    
                alert('The city of ' + openc + ' is located in ' + openc + '.');
            });
        });
    </script>
    

    Also, as stated in the comments Ids cannot start with numbers, so it’d be best to change those too.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know this is probably a very simple question but how would I do
there is probably a very simple answer to this very simple question, but i
This is probably a very simple question, but at this time I have myself
I know this is probably a very simple question, but I can't seem to
This is probably very simple but it's really confusing me. When I implement the
This one is probably very simple, but I can't seem to get it working.
I searched a bit, but couldn't find an answer to this (probably very simple)
This is probably a very dumb question, but I had a few questions about
I was making this very simple lex program (just an introductory program). But on
Probably very simple question (I just want to ensure I'm right). Title is not

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.