0

Hi folks,

I am aware this is a problem that many people have, but I am yet to find an answer...

I have a 10x10 grid generated using a html <table>, each cell has an id reffering to its location (ie. #15 - row 1, colmn 5).

All I need is a snippet that will take the cell id, and add one -> #15 becomes #16, rather than #151...

I can use normal Javascipt or jQuery, whichever is easiest :)

Thanks in advance!

2
Contributors
4
Replies
20
Views
4 Years
Discussion Span
Last Post by LastMitch
0

I am aware this is a problem that many people have, but I am yet to find an answer...

What problem? You need to explain a little more.

You need to used this:

http://api.jquery.com/Types/

All I need is a snippet that will take the cell id, and add one -> #15 becomes #16, rather than #151...

I hope you don't expect someone to write it out? What code have you done so far? If you done something psot what you have so we can get an better idea how to approached this.

0

I need to click on #11, and somehow reach the value 12.. I have since learned how to do this using the prev() function...

I now am faced with a slightly different problem... If I click #11, how do I get to 21? Because if I do $(this).attr('id') + 10, I get 1110. Any ideas?

html:

<table>
    <tr>
        <td id="10"></td>
        <td id="11"></td>
        ...
        <td id="19"></td>
    </tr>
    <tr>
        <td id="20"></td>
        <td id="21"></td>
        ...
        <td id="29"></td>
    </tr>
    ...
</table>

Sorry for not explaining so well before...

0

Never mind folks, solved with:

var possB = $(this).prev("td").attr("id") 
    possB = possB * 2 - (possB - 11);
0

I now am faced with a slightly different problem... If I click #11, how do I get to 21? Because if I do $(this).attr('id') + 10, I get 1110. Any ideas?

I'm glad you solve it! I wasn't too sure what you are planning to do with that.

I found this

http://www.randomsnippets.com/2011/04/10/how-to-hide-show-or-toggle-your-div-with-jquery/

Since you want your

<td id="10"></td> 

to go to

<td id="21"></td>

and this (I assuming you are putting image in the div tags):

http://jquerymobile.com/demos/1.0a2/experiments/api-viewer/docs/attr/

Edited by LastMitch: grammer

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.