Omission
Apr 26th 2007, 4:36 am
Anyone got any ideas how to achieve this. I want a border of an image to change when i select a certain link, for example
TEXT1 [IMAGE1]
When i highlight Text1 (which is a link) IMAGE1's border will change colour.
I found this
<script type="text/javascript">
window.onload = function() {
var o = document.getElementById('container');
var p = o.getElementsByTagName('img');
for (i = 0; p.length > i; i++) {
p[i].onmouseover = function() {this.style.borderColor = '#f33' };
p[i].onmouseout = function() { this.style.borderColor = '#ccc' };
}
}
</script>
Which I tried to adapt to
<script type="text/javascript">
window.onload = function() {
var o = document.getElementById('container');
var p = o.getElementsByTagName('img');
var l = o.getElementsByTagName('li');
for (i = 0; l.length > i; i++) {
l[i].onmouseover = function() { l[i].style.borderColor = '#f33' };
l[i].onmouseout = function() { l[i].style.borderColor = '#ccc' };
}
}
</script>
where the text links are contained withing <li> tags.... any ideas?
TEXT1 [IMAGE1]
When i highlight Text1 (which is a link) IMAGE1's border will change colour.
I found this
<script type="text/javascript">
window.onload = function() {
var o = document.getElementById('container');
var p = o.getElementsByTagName('img');
for (i = 0; p.length > i; i++) {
p[i].onmouseover = function() {this.style.borderColor = '#f33' };
p[i].onmouseout = function() { this.style.borderColor = '#ccc' };
}
}
</script>
Which I tried to adapt to
<script type="text/javascript">
window.onload = function() {
var o = document.getElementById('container');
var p = o.getElementsByTagName('img');
var l = o.getElementsByTagName('li');
for (i = 0; l.length > i; i++) {
l[i].onmouseover = function() { l[i].style.borderColor = '#f33' };
l[i].onmouseout = function() { l[i].style.borderColor = '#ccc' };
}
}
</script>
where the text links are contained withing <li> tags.... any ideas?