On Dec 3, 3:54 pm, "K.C.Leung" <[EMAIL PROTECTED]> wrote:
> Are there and table mehods for Table to make easier ?
>
> <table><tbody>
>     <tr>
>          <td>Top Left</td>
>          <td>Top</td>
>          <td>Top Right</td>
>
>     <tr>
>          <td>Left</td>
>
>          <td><div>
>              <a href="#" id="center">center</a>
>          </div></td>
>
>          <td>Right</td>
>     </tr>
>
>     <tr>
>          <td>Bottom Left</td>
>          <td>Bottom</td>
>          <td>Bottom Right</td>
>     </tr>
> </tbody></table>
>
> <script type="text/javascript">
> var center = $( "center" ) ;
> center.selectUp ( ).innerHTML ;     // Top
> center.selectDown ( ).innerHTML   // Bottom
> center.selectLeft ( ).innerHTML      // Left
> center.selectRight ( ).innerHTML    // Right
>
> center.selectUp ( ).selectLeft ( ).innerHTML // TopLeft
> </script>

Perthaps something like this:

(function(){

  function indexOf(element) {
    return Array.prototype.indexOf
      .call(element.parentNode.childNodes, element);
  }

  Element.addMethods({
    getTopCell: function(element) {
      return element.up('tr').previous()
        .down('td', indexOf(element));
    },
    getBottomCell: function(element) {
      return element.up('tr').next()
        .down('td', indexOf(element));
    },
    getLeftCell: function(element) {
      return element.previous('td');
    },
    getRightCell: function(element) {
      return element.next('td');
    }
  })
})();

--
kangax
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to