![]() |
Variable GetElementByID?
Hi, quick question:
Code:
function x() { |
Code:
document.getElementById('myid'+i) |
Quote:
Code:
var i = [0-9]; |
no.
first you have to figure out how many elements you're working with. If you're working with every div on your page, it's simple using document.getElementsByTagName("div")then you loop through them. here's a simple example: Code:
<body> |
Quote:
Code:
<script type="text/javascript">Code:
<script type="text/javascript"> |
Wow, this is getting rather complicated. Thank you for your help. I'd like to keep things simple, where possible. I'm trying to get around the ElementByID restrictions with the code below, but it doesn't work:
Code:
function plus() {Code:
<a href="javascript:plus();">+</a>Code:
.testclass { |
no, that's not going to work - getElementsByTagName returns a collection, even if there is only one element in the collection. You can select it like this:
Code:
function plus() { |
Quote:
|
depends what you call difficult. you have to loop through them all, but that's no big deal:
Code:
function plus() { |
Quote:
Code:
Message: Invalid argument. |
:confused:
looks ok to me. What's on line 5 of your code? Or better, can we see your full code? |
Quote:
Code:
function plus() {Code:
<!DOCTYPE html>Code:
html { |
now I'm even more confused :(
This works: Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">W T F ? since when could you not override css with the DOM? sorry, Charlie, but this is where I jump off... maybe someone who knows what's going on would like to have a shot at it? |
Thanks, xelawho. After you described your tests, I made some changes. First, rather than assign a class to each image tag, I simply added those properties under the IMG tag in the CSS file.
Code:
img {Code:
function pagesize () {Code:
<body onload="pagesize()"> |
| All times are GMT +1. The time now is 05:33 PM. |
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.