hi there i am pretty new to javascript, and i am trying my hardest to make this work.
what i have so far:
if (!document.myGetElementsByClassName) {
document.myGetElementsByClassName = function(className) {
var children = document.getElementsByTagName('*') || document.all;
var elements = new Array();
for (var i = 0; i < children.length; i++) {
var child = children;
var classNames = child.className.split(' ');
for (var j = 0; j < classNames.length; j++) {
if (classNames[j] == className) {
elements.push(child);
var dooreflections = elements.getElementsByTagName('img');
break;
}
}
}
return dooreflections;
}
}
and then:
function addReflections() {
var rimages = document.myGetElementsByClassName('test');
for (i=0;i<rimages.length;i++) {
var rheight = null;
var ropacity = null;
var classes = rimages.className.split(' ');
for (j=0;j<classes.length;j++) {
if (classes[j].indexOf("rheight") == 0) {
var rheight = classes[j].substring(7)/100;
} else if (classes[j].indexOf("ropacity") == 0) {
var ropacity = classes[j].substring(8)/100;
}
}
Reflection.add(rimages, { height: rheight, opacity : ropacity});
}
}
my html:
<div class="test"><img src="someimage" /></div>
<div class="notwanted"><img src="someimage" /></div>
<div class="test"><img src="someimage" /></div>
what i have so far:
if (!document.myGetElementsByClassName) {
document.myGetElementsByClassName = function(className) {
var children = document.getElementsByTagName('*') || document.all;
var elements = new Array();
for (var i = 0; i < children.length; i++) {
var child = children;
var classNames = child.className.split(' ');
for (var j = 0; j < classNames.length; j++) {
if (classNames[j] == className) {
elements.push(child);
var dooreflections = elements.getElementsByTagName('img');
break;
}
}
}
return dooreflections;
}
}
and then:
function addReflections() {
var rimages = document.myGetElementsByClassName('test');
for (i=0;i<rimages.length;i++) {
var rheight = null;
var ropacity = null;
var classes = rimages.className.split(' ');
for (j=0;j<classes.length;j++) {
if (classes[j].indexOf("rheight") == 0) {
var rheight = classes[j].substring(7)/100;
} else if (classes[j].indexOf("ropacity") == 0) {
var ropacity = classes[j].substring(8)/100;
}
}
Reflection.add(rimages, { height: rheight, opacity : ropacity});
}
}
my html:
<div class="test"><img src="someimage" /></div>
<div class="notwanted"><img src="someimage" /></div>
<div class="test"><img src="someimage" /></div>