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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T01:44:10+00:00 2026-06-14T01:44:10+00:00

I am making a game in javascript and I needed help with the following:

  • 0

I am making a game in javascript and I needed help with the following:

I want to make an image = to a variable then I only want to show the image when I want it too.

So I want the image by default hidden but it is always showing whatever I do. I am only a beginner and I have looked at this page and others on the internet to help me: http://www.roseindia.net/javascript/javascriptexamples/javascript-hide-image.shtml

This is the code so far:

<html> <head></head>
<body>
     <img src="http://wwcdn.weddingwire.com/static/vendor/55001_60000/56375/thumbnails/64x‌​64_SQ_1342622451725-Matangiaerial.jpg"
          id="islandimg">
     <script type="text/javascript">
     var playermoney = 10000;
     var islandarray = new array;
     var car = 500; var watch = 100;
     var diamond = 2000;
     function hideImage() { 
          if (document.getElementById) {
               document.getElementById('islandimg').style.visibility = 'hidden';
          }
     </script>
</body></html>

The code has other stuff in it for the game but ignore it.

  • 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-14T01:44:12+00:00Added an answer on June 14, 2026 at 1:44 am

    You could use jQuery and do this:

    function hideImage() {
      $('#islandimg').hide();
    }
    

    UPDATE:

    An other option would be this:

    function hideImage() { 
        document.getElementById('islandimg').style.visibility = 'hidden';
    }
    

    or this:

    function hideImage() { 
        document.getElementById('islandimg').style.display = 'none';
    }
    

    Whats the difference between the last two => http://webdesign.about.com/od/css/f/blfaqhidden.htm

    It seams you want to toggle the visible state of the image so you should create a show function too. (By using jQuery you can use the toggle() function for that.)

    If you don’t want to display the image you could also hide it with CSS by default and then toggle the display state with JavaScript with your showImage() function.

    #islandimg {
        visibility: hidden;
    }
    

    or

    #islandimg {
        display: none;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm making a javascript game in which I want enemy ships to be able
I'm making a javascript game without using canvas, and I want the screen to
I'm making a game engine in Javascript, and I want to have a camera
I am making a 2D game in javascript/ajax, that will be using data stored
I'm making a simple game in Javascript, in which when an object collides with
I am making a game in java and I want to create a simulation
I'm making a game using javascript + canvas. I use the code below to
I'm making a javascript game and need to bind a lot of keys to
I am making a simple PHP and JavaScript multiplayer game. Here is a quick
I am making a Javascript game with the canvas tag, and I am using

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.