View previous topic :: View next topic |
Author |
Message |
gog
Joined: 18 Jun 2004 Posts: 679 Location: zagreb
|
Posted: 21.06.2006 11:52 Post subject: getElementsByTagName |
|
|
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 |
|
|
sinisa.kusic
Joined: 26 Jul 2005 Posts: 728 Location: Rijeka
|
Posted: 21.06.2006 12:01 Post subject: |
|
|
gog, aj molim te prepravi title topic-a. razbio si layout na indexu.. stavi nešto s razmacima
PS: sorry za OT, al mrsko mi je vidjet razvaljen layout |
_________________ some are born awesome, some achieve awesomeness and some have awesomeness thrust upon them |
|
Back to top |
|
|
Sulien
Joined: 04 Jan 2004 Posts: 2905 Location: Zagreb
|
Posted: 21.06.2006 12:16 Post subject: |
|
|
Table bez tbody je sam svoj tbody
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 |
|
|
gog
Joined: 18 Jun 2004 Posts: 679 Location: zagreb
|
Posted: 21.06.2006 13:05 Post subject: |
|
|
Sulien wrote: | Table bez tbody je sam svoj tbody |
Da, to sam si i mislio...
Sulien wrote: | BTW ako si na Prototype probaj "splintered striper" kojeg sam doradio |
Nisam, ali ostat će u bookmarksima, za svaki slučaj Tnx... |
|
|
Back to top |
|
|
|