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!

Member Avatar for LastMitch

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.

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...

Never mind folks, solved with:

var possB = $(this).prev("td").attr("id") 
    possB = possB * 2 - (possB - 11);
Member Avatar for LastMitch

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/

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.