Forum FAQForum FAQSearchSearch MemberlistMemberlist Forum ignore listForum ignore list RegisterRegister ProfileProfile Log in to check your private messagesLog in to check your private messages Log inLog in
getElementsByTagName

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    mi3dot.org Forum Index -> Client-side
View previous topic :: View next topic  
Author Message
gog



Joined: 18 Jun 2004
Posts: 679
Location: zagreb

PostPosted: 21.06.2006 11:52    Post subject: getElementsByTagName Add user to your forum ignore list Reply with quote

Code:

var stripe = function() {
   var tables = document.getElementsByTagName("table");   

   for(var x=0;x!=tables.length;x++){
      var table = tables[x];
      if (! table) { return; }
      
      var tbodies = table.getElementsByTagName("tbody");
      
      for (var h = 0; h < tbodies.length; h++) {
         var even = true;
         var trs = tbodies[h].getElementsByTagName("tr");
         
         for (var i = 0; i < trs.length; i++) {
            trs[i].onmouseover=function(){
               this.className += " ruled"; return false
            }
            trs[i].onmouseout=function(){
               this.className = this.className.replace("ruled", ""); return false
            }
            
            if(even)
               trs[i].className += " even";
            
            even = !even;
         }
      }
   }
}


Zanima me zašto unatoč "table.getElementsByTagName("tbody")" ova JS "procesuira" i one <tr>-ove koji se nalaze u tablici koja uopće ne sadrži <tbody> element? Da li ukoliko nema <tXXXXX> elemenata unutar <table> sve što je unutar <table> je ujedno i unutar <tobdy> ili ima neka druga fora?

Last edited by gog on 21.06.2006 13:03; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website
sinisa.kusic



Joined: 26 Jul 2005
Posts: 728
Location: Rijeka

PostPosted: 21.06.2006 12:01    Post subject: Add user to your forum ignore list Reply with quote

gog, aj molim te prepravi title topic-a. razbio si layout na indexu.. stavi nešto s razmacima Smile

PS: sorry za OT, al mrsko mi je vidjet razvaljen layout Very Happy

_________________
some are born awesome, some achieve awesomeness and some have awesomeness thrust upon them
Back to top
View user's profile Send private message Send e-mail MSN Messenger
Sulien



Joined: 04 Jan 2004
Posts: 2905
Location: Zagreb

PostPosted: 21.06.2006 12:16    Post subject: Add user to your forum ignore list Reply with quote

Table bez tbody je sam svoj tbody Smile

BTW ako si na Prototype probaj "splintered striper" kojeg sam doradio

Code:
/* Splintered striper 1.5
 *
 * Reworking of Zebra Tables and similar methods which works not only for tables and even/odd rows,
 * but as a general DOM means of assigning any number of classes to children of a parent element.
 *
 * Core experiment function that applies any number of classes to all child elements contained in
 * all occurences of a parent element (either with or without a specific class)
 *
 * @author    Patrick H. Lauke aka redux
 * @author    Mislav Marohnić <mislav@nippur.irb.hr>
 * @license   CC Attribution-ShareAlike license - http://creativecommons.org/licenses/by-sa/2.0/
 * @param     parentElementTag - parent tag name
 * @param     parentElementClass - matches only a parent with this class
 * @param     childElementTag - tag name of the child elements to apply the styles to
 * @param     styleClasses - array or comma-separated classnames to cycle
 */
function striper(parentElementTag, parentElementClass, childElementTag, styleClasses){
   // capability and sanity check
   if(document.getElementsByTagName && parentElementTag && childElementTag && styleClasses){
      // turn the comma separate list of classes into an array
      var classes = typeof styleClasses=='string' ? styleClasses.split(',') : styleClasses;
      
      $A(document.getElementsByTagName(parentElementTag)).each(function(el){
         var i=0;
         // do we have a class restriction?
         if(!parentElementClass || Element.hasClassName(el, parentElementClass)){
            $A(el.getElementsByTagName(childElementTag)).each(function(child){
               Element.addClassName(child, classes[(i++)%classes.length]);
               if(i==classes.length) i=0;
            });
         }
      });
   }
}
Back to top
View user's profile Send private message Send e-mail Visit poster's website
gog



Joined: 18 Jun 2004
Posts: 679
Location: zagreb

PostPosted: 21.06.2006 13:05    Post subject: Add user to your forum ignore list Reply with quote

Sulien wrote:
Table bez tbody je sam svoj tbody Smile


Da, to sam si i mislio... Sad

Sulien wrote:
BTW ako si na Prototype probaj "splintered striper" kojeg sam doradio


Nisam, ali ostat će u bookmarksima, za svaki slučaj Smile Tnx...
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    mi3dot.org Forum Index -> Client-side All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group