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

  • Home
  • SEARCH
  • 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 9229035
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T05:28:25+00:00 2026-06-18T05:28:25+00:00

I have this code for a small jQuery game I’m making, and all the

  • 0

I have this code for a small jQuery game I’m making, and all the pictures (characters) are hidden by default. There’s a question that says “Are you ready to play?” and a yes or no button. When you click the yes button, it hides the buttons and the text. It is also supposed to display the first image, which is #main. For some reason, it’s not working.
Here’s the jQuery code with the images under:

$(document).ready(function(){
$('#main,#batman,#car,#hobo,#knife,#gangfight,#ganggun,#gangknife,#blood').hide(-100);  
var main=$('#main');  
 batman=$('#batman');  
 car=$('#car');
 hobo=$('#hobo');
 cop=$('#cop');
 knife=$('#knife');
 gangfight=$('#gangfight');
 ganggun=$('#ganggun');
 gangknife=$('#gangknife');
 blood=$('#blood');
    document.write('<title>LOAUP</title>');
    document.write('<center><h1>The life of an unlucky person</h1></center>');
    document.write('<center id="start">Are you ready to play?</center>');
    document.write('<center><button id="yes">Yes</button><button id="no">No</button></center>');
    $('#yes').click(function(){
        $('#yes,#no').hide(function(){
            $('#start').hide();
            $('#main').show
        });
        });
    $('#no').click(function(){
        $('#yes,#no').hide();
        $('#start').hide();
        document.write('<center>Ok, come back another time then.</center>');
    });
});
//Images below this (HTML)
<img id='main' src='/jquery/sprites/spritePerson.png' />
    <img id='batman' src='/jquery/sprites/spriteBatman.png' />
    <img id='car' src='/jquery/sprites/spriteCar.png' />
    <img id='hobo' src='/jquery/sprites/spriteHobo.png' />
    <img id='cop' src='/jquery/sprites/spriteCop.png' />
    <img id='knife' src='/jquery/sprites/spriteKnife.png' />
    <img id='gangfight' src='/jquery/sprites/spriteGangFight.png' />
    <img id='ganggun' src='/jquery/sprites/spriteGangGun.png' />
    <img id='gangknife' src='/jquery/sprites/spriteGangKnife.png' />
    <img id='blood' src='/jquery/sprites/spriteBloodPuddle.png' />

Edit:

Here’s the example:
http://jsbin.com/ocowas/1

  • 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-18T05:28:26+00:00Added an answer on June 18, 2026 at 5:28 am

    In your #main click function change

    $('#main').show
    

    to

    $('#main').show();
    

    Your variable list should be comma seperated not colon seperated. and you may also want to rename your variables to make them more obvious and easier to read/remember by prefixing with a $ sign. For example when you store a selector as a variable use

    var $element = $('#element'),
        $element2 = $('#element2'),
        $element23 = $('#element23');
    

    Further, the hide() function does not take negative numbers as you have used. Just use hide() for an instant hide, or hide(100) for fast, hide(2000) for slow.. check: http://docs.jquery.com/Effects/hide

    To append html to your document without using document.write, you can store the html as a variable, then select the body tag, or any other tag and append/prepend or replace the html to that, for example.

    $('body').append(yourHTMLvar);
    $('body').prepend(yourHTMLvar);
    $('body').html(yourHTMLvar);
    

    The ‘title’ tag should only appear between the ‘head’ tags of your html document. Use a heading tag instead, ‘h1’ to ‘h6’.
    The html ‘center’ tag is also deprecated as far as I know. Try using ‘span’, ‘p’ or even ‘div’ instead.

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

Sidebar

Related Questions

peace folks, I have this small piece of jquery based code, that grabs all
I have this small piece of code that basically takes a list and runs
Work on this small test application to learn threading/locking. I have the following code,
Strange Question i guess but i have this bit of code in my page...
I have a small requirement.. Please someone help me I have this code to
sorry, im new in jquery. I have this code on tag: <img class=fluidimage src=img/picture1.jpg/>
I have this post request code in jquery, which seems to send the request
I have this code blocks from W3Schools sample of JQuery. Try it on W3Schools
I have this jquery code which works great: $(document).scroll(function(){ if ($(this).scrollTop()>175){ // animate fixed
I have this small problem with jquery: I need to do something like this:

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.