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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T01:23:33+00:00 2026-05-25T01:23:33+00:00

I am programming a Javascript game as an exercise in objects and AJAX. It

  • 0

I am programming a Javascript game as an exercise in objects and AJAX. It involves movement of wessels around a nautical-themed grid. Although the wessels are in an array of objects, I need to manipulate their graphical representation, their sprites. At the moment I have chosen, from a DOM perspective, to use ‘img’ elements within ‘td’ elements.
From a UI continuity perspective, which method of programmatically moving the elements with Javascript would be recommended:
(a) deleting inner html of ‘from’ cell (td element) and rewriting inner html of ‘to’ cell,
(b) clone the img node (sprite), delete the original node from its parent, and append it to the ‘to’ cell, or
(c) using positioning relative to the table element for the sprite, ignoring the td’s alltogether (although their background [color] represents the ocean depth).

  • 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-25T01:23:34+00:00Added an answer on May 25, 2026 at 1:23 am

    I would definitely stick with moving the sprite from cell to cell rather than using relative positioning to the table. My reasoning is that the table cell size might vary from browser to browser (given variances in the way padding, margins etc. are rendered – especially with annoying IE) and calculating the exact location to position the sprite in order for it to line up within a given cell might get complicated.

    That narrows it down to (a) or (b) for your options. Here let’s eliminate option (a), as deleting the HTML from inside is not a clean way of manipulating the DOM. I like the idea of storing the node in an object, and then appending it to the ‘to’ cell, and then deleting the original node, which your option (b) suggests. This way, you are still dealing with the high-level ‘objects’ and not the low-level ‘text’ needlessly. You don’t need to mess with the text – for such an application, that would be the dirty ‘hackish’ way of doing it if you didn’t know about the DOM manipulation functions JavaScript already offers.

    My answer is (b). However, if you absolutely require speed – though for your game I don’t know if you’ll really need the extra boost – you may consider option (a). A few sources, such as http://www.quirksmode.org/dom/innerhtml.html contend that the DOM manipulation methods are generally slower than using innerHTML. But that’s the general rule with everything. The lower the level you go, the faster you can make your code. The higher the level, the easier to understand and conceptualize the code is, and in my opinion, since speed will not make a huge difference in this case, keep it neat and go with (b).

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

Sidebar

Related Questions

I know that Javascript is an incredibly unsecure way of programming a persistent game,
I'm finding lately how unsecure Javascript is when programming a game (I'm trying to
In interpreted programming languages, such as PHP and JavaScript, what are the repercussions of
Where X is any programming language (C#, Javascript, Lisp, Perl, Ruby, Scheme, etc) which
I have been programming using PHP, Javascript and have been a designer for a
I am looking get to grips with functional programming concepts. I've used Javascript for
I do a lot of XSLT programming. I also do Java, PL/SQL, JavaScript, and
I'm looking to learn some fundamentals on cartesian geometry or coordinates based game programming.
I'm a beginner in programming. I've just made a program called Guessing Game. And
I'm working on a simple board game using Appcelerator Titanium for iPhone (javascript -

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.